Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
5.0.3
-
None
-
Android
Description
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 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(), which generates a ClassicHttpResponse with a ByteArrayEntity from a cache entry, dropping the conent-encoding header in the process.