Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection leak on gzip/deflate responses #588

Open
jefimm opened this issue Feb 28, 2021 · 4 comments
Open

connection leak on gzip/deflate responses #588

jefimm opened this issue Feb 28, 2021 · 4 comments

Comments

@jefimm
Copy link

jefimm commented Feb 28, 2021

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

@rymndhng
Copy link
Collaborator

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.

@jefimm
Copy link
Author

jefimm commented Mar 13, 2021

The usage of the function https://github.com/dakrone/clj-http/blob/master/src/clj_http/client.clj#L280 leaks the stream

@rymndhng
Copy link
Collaborator

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

@jefimm
Copy link
Author

jefimm commented Mar 13, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants