I'm trying to process a server response which is GZIP'd. The response comes with a header
Content-Type: application/x-gzip
but does not have header
Content-Encoding: gzip
If I add that header using a proxy, the response gets parsed just fine. I don't have any control over the server, so I can't add the header.
Can I force Retrofit to treat it as GZIP content? Is there a better way? The URL for the server is: http://crowdtorch.cms.s3.amazonaws.com/4474/Updates/update-1.xml
I figured it out. The idea is to add a custom interceptor which will take the not-yet-unzipped response, and unzip it 'manually' - do the same thing that OkHttp would do automatically based on Content-Encoding header, but without requiring that header.
is like dis:
And the Interceptor is like dis:
And the unzip function is like dis:
There is a better way than reinventing the wheel. Just add the
Content-Encoding
header yourself.In fact, your code is a classic example of the evils of using internal code (like
com.sun
packages from the JDK).RealResponseBody
doesn't have that constructor anymore.