{"action":"created","issue":{"url":"https://api.github.com/repos/square/okhttp/issues/1927","labels_url":"https://api.github.com/repos/square/okhttp/issues/1927/labels{/name}","comments_url":"https://api.github.com/repos/square/okhttp/issues/1927/comments","events_url":"https://api.github.com/repos/square/okhttp/issues/1927/events","html_url":"https://github.com/square/okhttp/issues/1927","id":111697602,"number":1927,"title":"OkHTTP does not unzip Gzipped content when using Authenticator","user":{"login":"tyvsmith","id":309657,"avatar_url":"https://avatars.githubusercontent.com/u/309657?v=3","gravatar_id":"","url":"https://api.github.com/users/tyvsmith","html_url":"https://github.com/tyvsmith","followers_url":"https://api.github.com/users/tyvsmith/followers","following_url":"https://api.github.com/users/tyvsmith/following{/other_user}","gists_url":"https://api.github.com/users/tyvsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/tyvsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tyvsmith/subscriptions","organizations_url":"https://api.github.com/users/tyvsmith/orgs","repos_url":"https://api.github.com/users/tyvsmith/repos","events_url":"https://api.github.com/users/tyvsmith/events{/privacy}","received_events_url":"https://api.github.com/users/tyvsmith/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/square/okhttp/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-15T20:10:03Z","updated_at":"2015-10-15T22:07:59Z","closed_at":null,"body":"Using OkHttp 2.5\r\n\r\nI'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.\r\n\r\n```\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: <--- HTTP 200 (775ms)\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: Content-Encoding: gzip\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: Content-Type: application/json; charset=utf-8\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: Date: Thu, 15 Oct 2015 20:03:42 GMT\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: Server: nginx\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: Status: 200 OK\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: X-Runtime: 0.079625\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: X-UA-Compatible: IE=Edge,chrome=1\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: Content-Length: 146\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: Connection: keep-alive\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: OkHttp-Selected-Protocol: http/1.1\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: OkHttp-Sent-Millis: 1444939422732\r\n10-15 16:03:42.900 18864-18889/com.example.dev D/Retrofit: OkHttp-Received-Millis: 1444939422900\r\n10-15 16:03:42.901 18864-18889/com.example.dev D/Retrofit: \u001F�\b������������\u0003]�A\r\n10-15 16:03:42.901 18864-18889/com.example.dev D/Retrofit: � \u0014D��׶�F+z�\u0010D�\u0017��\u00045�\"x�j7-��̛Y�\t\u0019S�\fj�n�19JF)\u0011�L \u0017�\r\n10-15 16:03:42.901 18864-18889/com.example.dev D/Retrofit: �\u001F\f\u000Ec1m|�\u000B�'&�]'�N�d�\u0012�\u0015�e��?�J��\u000E\u000E\u0014p� ��r�\u0016?4�w `�\u0010����\u0012��_�7�3�'�������\r\n10-15 16:03:42.901 18864-18889/com.example.dev D/Retrofit: <--- END HTTP (146-byte body)\r\n```\r\n\r\n```java\r\n    private Request refreshAndSign(Response response, AccessToken token) {\r\n        AccessToken freshToken = service.refreshAccessToken(token.refreshToken);\r\n        accessTokenState.setAccessToken(freshToken);\r\n\r\n        Request.Builder builder = response.networkResponse().request().newBuilder();\r\n        setAuthHeader(builder, freshToken);\r\n        return builder.build();\r\n    }\r\n```\r\n\r\nThis is worked around by explicitly removing the header when resigning.\r\n\r\n```java\r\nbuilder.removeHeader(\"Accept-Encoding\");\r\n```"},"comment":{"url":"https://api.github.com/repos/square/okhttp/issues/comments/148537182","html_url":"https://github.com/square/okhttp/issues/1927#issuecomment-148537182","issue_url":"https://api.github.com/repos/square/okhttp/issues/1927","id":148537182,"user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"created_at":"2015-10-15T22:07:59Z","updated_at":"2015-10-15T22:07:59Z","body":"Did you try OkHttp 2.5? OkHttp 2.0 is really, really old.\n\nOn Thu, Oct 15, 2015 at 5:54 PM Jesse Wilson <notifications@github.com>\nwrote:\n\n> Eep. I thought we'd fixed all of these.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/square/okhttp/issues/1927#issuecomment-148532540>.\n>\n"}}