From 510fe200d7652f97386a996bc76d078d8558a837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 29 Oct 2024 10:27:41 +0100 Subject: [PATCH] Make sure all bytes written are flushed Currently BkBasic uses a BufferedOutputStream, so all content is first buffered before send to the actual stream. While the stream is implicitly flushed after writing headers, it is not when writing the body. So if the body is quite small it might never been send to the socket before close. This now explicitly flush the content after calling print to not loose bytes regardless of how the printing is actually implemented. --- src/main/java/org/takes/http/BkBasic.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/takes/http/BkBasic.java b/src/main/java/org/takes/http/BkBasic.java index 2a8be254e..590b732dd 100644 --- a/src/main/java/org/takes/http/BkBasic.java +++ b/src/main/java/org/takes/http/BkBasic.java @@ -103,6 +103,7 @@ public void accept(final Socket socket) throws IOException { ), output ); + output.flush(); if (input.available() <= 0) { break; }