Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2157

Gzip decompression not applied with Apache CachingHttpClient version 5.0.3

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.0.3
    • 5.0.4, 5.1
    • HttpClient (classic)
    • 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.
       
       

      Attachments

        Activity

          People

            Unassigned Unassigned
            Gunther H Gunther Heppner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: