Skip to content

Commit 84382e9

Browse files
committed
Avoid buffering - next ISeq chunk may be delayed
The ISeq elements may be delayed at source, thus causing an unnecessary wait at the client end for the output. We flush the writer after writing out every ISeq element. This makes implementing Server-sent Events smooth as well.
1 parent cca9a7b commit 84382e9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

ring-core-protocols/src/ring/core/protocols.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
(write-body-to-stream [body response output-stream]
5656
(with-open [writer (response-writer response output-stream)]
5757
(doseq [chunk body]
58-
(.write writer (str chunk)))))
58+
(.write writer (str chunk))
59+
(.flush writer))))
5960
java.io.InputStream
6061
(write-body-to-stream [body _ ^OutputStream output-stream]
6162
(with-open [body body]

0 commit comments

Comments
 (0)