-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
OkHTTP does not unzip Gzipped content when using Authenticator #1927
Comments
Eep. I thought we'd fixed all of these. |
Did you try OkHttp 2.5? OkHttp 2.0 is really, really old. On Thu, Oct 15, 2015 at 5:54 PM Jesse Wilson notifications@github.com
|
@JakeWharton I edited it to 2.5 after the first post. |
It seems that response body isn't ungzipped automatically every time you specify "Accept-Encoding: gzip" header manually in a request. |
By adding that header you are informing OkHttp that you can accept On Wed, Nov 18, 2015 at 2:21 PM Alexei Moisseev notifications@github.com
|
@tyvsmith By the way, is it really necessary for you to use raw headers ( Request.Builder builder = response.request().newBuilder();
setAuthHeader(builder, freshToken); |
@alexeimoisseev At first glance that seems accurate, however, it appears like already existing headers only exist on the networkResponse.request(). Using the builder you recommended would lose other headers set. |
@tyvsmith I think the right fix is to avoid using - Request.Builder builder = response.networkResponse().request().newBuilder();
+ Request.Builder builder = response.request().newBuilder(); |
@swankjesse unfortunately, by using response.request(), all headers are stripped, including ones I injected with interceptors. Is this the desired behavior or is there a recommended alternative approach? |
Using OkHttp 2.5
I'm using an Authenticator to catch 401's and refresh my OAuth token. Upon retrying the requests, GSON fails at parsing a compressed String. Since OkHTTP silently adds the "Accept-encoding: gzip" header after the first try, upon retrying with the Authenticator it sees the existing header for "Accept-encoding" and does not do the unzipping.
This is worked around by explicitly removing the header when resigning.
The text was updated successfully, but these errors were encountered: