-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gzip Handling Error #31
Comments
To see how the response is further handled, you can have a look at the okHttp BridgeInterceptor(line 100) |
Version 2.0.6
|
I am using Retrofit 2.1.0 together with gson-Converter 2.1.0 and LoggingInterceptor 2.0.2.
If i call a service returning a response with "Content-Encoding: gzip" the following exception occurs.
java.io.IOException: ID1ID2: actual 0x00001fef != expected 0x00001f8b at okio.GzipSource.checkEqual(GzipSource.java:205) at okio.GzipSource.consumeHeader(GzipSource.java:120) at okio.GzipSource.read(GzipSource.java:73) at okio.RealBufferedSource.read(RealBufferedSource.java:45) at okio.ForwardingSource.read(ForwardingSource.java:35) at retrofit2.OkHttpCall$ExceptionCatchingRequestBody$1.read(OkHttpCall.java:279) at okio.RealBufferedSource.request(RealBufferedSource.java:66) at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:387) at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:371) at okhttp3.internal.Util.bomAwareCharset(Util.java:412) at okhttp3.ResponseBody$BomAwareReader.read(ResponseBody.java:248) at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1287) at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1325) at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:549) at com.google.gson.stream.JsonReader.peek(JsonReader.java:425) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:205) at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37) at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25) at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117) at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211) at retrofit2.OkHttpCall.execute(OkHttpCall.java:174) at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:89)
First step could be just ignoring responses with content-Encoding=gzip and just returning the raw response from the interceptor. (this would disable logging for gzip responses). Another option could maybe be direct usage of GzipResource to decompress the response body. But I think, then you would have to remove the Content-Encoding:gzip header for further response handling by okHttp.
The text was updated successfully, but these errors were encountered: