Gunther Heppner created HTTPCLIENT-2157:
-------------------------------------------
Summary: Gzip decompression not applied with Apache
CachingHttpClient version 5.0.3
Key: HTTPCLIENT-2157
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2157
Project: HttpComponents HttpClient
Issue Type: Bug
Components: HttpClient (classic)
Affects Versions: 5.0.3
Environment: Android
Reporter: Gunther Heppner
We are in the process of migrating from Apache HttpClient 4.5 to 5.0.3. Since
we want to do client side http caching we are using
{{CachingHttpClientBuilder}} to set up the HttpClient. With version 4.5.x this
works fine and gzip-encoded responses are automatically decompressed. However,
with version 5.0.3, the responses are returned as uncompressed
{{ByteArrayEntity}} and the {{Conent-Encoding}} header is missing from the
returned {{ByteArrayEntity}}, which prevents the default gzip decompression to
be applied.
Note - I was able to get gzip decompression with the default HttpClient.
Steps to reproduce:
* Run [this
code|https://stackoverflow.com/questions/67318260/gzip-decompression-not-working-with-apache-cachinghttpclient-version-5-0-3]
with HttpClient 5.0.3
* Observe the ` {{responseString}}` returned from `
{{EntityUtils.toString()}}` in the ` {{HttpClientResponseHandler}}`, which will
return a mangled string instead of a readable HTLM string
Based on some debugging, it looks like the bug might be in
[CachingExec.convert()|https://github.com/apache/httpcomponents-client/blob/e0c049060b45dcb9b93b7802edee3e5e4301cae5/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java],
which generates a {{ClassicHttpResponse}} with a {{ByteArrayEntity}} from a
cache entry, dropping the {{conent-encoding}} header in the process.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]