connection leak on gzip/deflate responses
jefimm opened this issue · 4 comments
It looks like https://github.com/dakrone/clj-http/blob/3.x/src/clj_http/util.clj#L45 and https://github.com/dakrone/clj-http/blob/3.x/src/clj_http/util.clj#L99 are leaking connections - the input stream argument is not closed
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.
The usage of the function https://github.com/dakrone/clj-http/blob/master/src/clj_http/client.clj#L280 leaks the stream
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