Closed rymndhng closed 4 years ago
Sounds good, thanks for the analysis :+1:
I did a bit further analysis and I've found some some new details, specifically HttpAsyncClientBuilder
does not support .disableContentCompression
. It also does not appear to be supported on 5.x.
I think it's important that a user's intuition of how a middleware works is consistent between sync and async requests. Therefore, I think the better fix is to set .disableContentCompression
for all requests and instead rely on clj-http middleware to decompress.
I also took a peek at how the underlying library implements decompression and it has the same logic as clj-http's middleware: wrapping the InputStream with GzipInputStream/DeflateInputStream by matching on content-encoding
.
Motivation
When a user wants to disable decompression, they should only have to specify one option. Currently, a user has to do two things:
:decompress-body false
:http-builder-fns
to disable it in Apache HTTPClientBuilder. See [HTTPClientBuidler#disableContentDecompression](https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/HttpClientBuilder.html#disableContentCompression()).Example, as discovered from #509:
Suggested Solution
We should remove the decompression implementation from clj-http since this functionality is delegated to Apache HTTPClient while respecting the option
:decompress-body
.core.clj
, detect the presence of:decompress-body
and configure(.disableContentCompression builder)
.wrap-decompression
from the list of middlewares (this is completely handled by ApacheHTTPClient).Cleanup the README's section on
Decompression
HTTPClientBuidler automatically. We should remove the function
decompression-request
since this functionality is now deferred to Apache HTTPClient.