Skip to content

Conversation

@elliotcourant
Copy link
Contributor

If a server responds with a Content-Encoding of something like deflate, gzip, clj-http would not be able to handle the response as the response body has been compressed using zlib and then compressed again using gzip.

This patch adds a recursive wrapper to the decompression handling that allows for multiple layers of compression to be unwrapped when receiving responses like this.

The content encoding header is split by commas, then in reverse order is decompressed layer by layer until the final body is produced which is then returned to the caller.

If a server responds with a `Content-Encoding` of something like
`deflate, gzip`, clj-http would not be able to handle the response as
the response body has been compressed using zlib and then compressed
again using gzip.

This patch adds a recursive wrapper to the decompression handling that
allows for multiple layers of compression to be unwrapped when receiving
responses like this.

The content encoding header is split by commas, then in reverse order is
decompressed layer by layer until the final body is produced which is
then returned to the caller.
@elliotcourant
Copy link
Contributor Author

@dakrone I'm happy to try to fix the CI/CD here too if you want, but it looks like its a caching/github actions issue and not something you might want me tampering with. Happy to take a swing at it though if you'd like.

Comment on lines 398 to 400
(assoc resp
:orig-content-encoding
(get-in resp [:headers "content-encoding"])))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be necessary since I've essentially lifted this into the decompression-response function at the start of the loop?

@dakrone
Copy link
Owner

dakrone commented Oct 19, 2025 via email

@elliotcourant
Copy link
Contributor Author

Thank you, no rush!

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

Successfully merging this pull request may close these issues.

2 participants