dakrone/clj-http

connection leak on gzip/deflate responses

jefimm opened this issue · 4 comments

These helper functions are intended to wrap an InputStream which is consumed by the client which is why they're not closed here.

The pattern: wrap with a buffered reader and call .read is used to check if the stream is open, to avoid wrapping closed streams.

At the point of code you've highlighted, it's decorating the body so that it can be consumed output-coercion-response middleware.

It's the client's responsibility to close the stream (through a coercion or explicitly by requesting the response as a stream). See https://github.com/dakrone/clj-http#output-coercion

Please compare this to code in force-string and force-byte-array - both close the stream