{"action":"created","issue":{"url":"https://api.github.com/repos/square/retrofit/issues/755","labels_url":"https://api.github.com/repos/square/retrofit/issues/755/labels{/name}","comments_url":"https://api.github.com/repos/square/retrofit/issues/755/comments","events_url":"https://api.github.com/repos/square/retrofit/issues/755/events","html_url":"https://github.com/square/retrofit/issues/755","id":58301038,"number":755,"title":"EOFException handling gzip response with Retrofit + OkHttp","user":{"login":"dfpalomar","id":5319517,"avatar_url":"https://avatars.githubusercontent.com/u/5319517?v=3","gravatar_id":"","url":"https://api.github.com/users/dfpalomar","html_url":"https://github.com/dfpalomar","followers_url":"https://api.github.com/users/dfpalomar/followers","following_url":"https://api.github.com/users/dfpalomar/following{/other_user}","gists_url":"https://api.github.com/users/dfpalomar/gists{/gist_id}","starred_url":"https://api.github.com/users/dfpalomar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfpalomar/subscriptions","organizations_url":"https://api.github.com/users/dfpalomar/orgs","repos_url":"https://api.github.com/users/dfpalomar/repos","events_url":"https://api.github.com/users/dfpalomar/events{/privacy}","received_events_url":"https://api.github.com/users/dfpalomar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-20T02:01:18Z","updated_at":"2015-03-10T13:07:10Z","closed_at":null,"body":"I'm trying to process a gzipped response from my web services but I'm always getting ***EOFException: source exhausted prematurely***. \r\n\r\nThese are the versions of my libraries:\r\n\r\n    retrofit: 1.9.0\r\n    okhttp: 2.2.0\r\n    okhttp-urlconnection: 2.2.0\r\n    gson: 2.3.1\r\n\r\nBelow my code and outputs:\r\n\r\n    RestAdapter restAdapter = new RestAdapter.Builder()\r\n        .setLogLevel(RestAdapter.LogLevel.FULL)\r\n        .setClient(new OkClient(new OkHttpClient()))\r\n        .setEndpoint(\"http://myserver.com/services\")\r\n        .build();\r\n\r\n    ... \r\n\r\n    @GET(\"/mobile/user/new\") \r\n    String registerNewAccount();\r\n\r\n*Request registered by Charles (debugging proxy)*\r\n\r\n    GET /services/mobile/user/new HTTP/1.1\r\n    User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9300 Build/JSS15J)\r\n    Host: myserver.com\r\n    Connection: Keep-Alive\r\n    Accept-Encoding: gzip\r\n\r\n*Response registered by Charles*\r\n\r\n    HTTP/1.1 200 OK\r\n    Date\tFri, 20 Feb 2015 00:47:13 GMT\r\n    Server\tApache-Coyote/1.1\r\n    Content-Encoding\tgzip\r\n    Content-Type\tapplication/json\r\n    Content-Length\t32\r\n    Via\t1.1 myserver.com\r\n    Keep-Alive\ttimeout=5, max=100\r\n    Connection\tKeep-Alive\r\n\r\n*Retrofit log output*\r\n\r\n    <--- HTTP 200 http://myserver.com/services/mobile/user/new (666ms)\r\n    Date: Fri, 20 Feb 2015 00:59:44 GMT\r\n    Server: Apache-Coyote/1.1\r\n    Content-Type: application/json\r\n    Via: 1.1 myserver.com\r\n    Keep-Alive: timeout=5, max=100\r\n    Proxy-Connection: Keep-alive\r\n    OkHttp-Selected-Protocol: http/1.1\r\n    OkHttp-Sent-Millis: 1424393970658\r\n    OkHttp-Received-Millis: 1424393971268\r\n    \r\n    ---- ERROR http://myserver.com/services/mobile/user/new\r\n    java.io.EOFException: source exhausted prematurely\r\n    \tat okio.InflaterSource.read(InflaterSource.java:77)\r\n    \tat okio.GzipSource.read(GzipSource.java:80)\r\n    \tat okio.RealBufferedSource$1.read(RealBufferedSource.java:298)\r\n    \tat java.io.InputStream.read(InputStream.java:163)\r\n    \tat retrofit.Utils.streamToBytes(Utils.java:43)\r\n    \tat retrofit.Utils.readBodyToBytesIfNecessary(Utils.java:81)\r\n    \tat retrofit.RestAdapter.logAndReplaceResponse(RestAdapter.java:483)\r\n    \tat retrofit.RestAdapter.access$500(RestAdapter.java:107)\r\n    \tat retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:338)\r\n    \tat retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)\r\n    \tat $Proxy0.registerNewAccount(Native Method)\r\n    \tat com.myapp.tasks.RegisterUserTask.doInBackground(RegisterUserTask.java:36)\r\n    \tat com.myapp.tasks.RegisterUserTask.doInBackground(RegisterUserTask.java:19)\r\n    \tat android.os.AsyncTask$2.call(AsyncTask.java:287)\r\n    \tat java.util.concurrent.FutureTask.run(FutureTask.java:234)\r\n    \tat android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)\r\n    \tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)\r\n    \tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)\r\n    \tat java.lang.Thread.run(Thread.java:841)\r\n    D/Retrofit(9508): ---- END ERROR\r\n\r\nI've been trying to figure out what's happening for hours with no results :$ Any help will be really appreciated :)"},"comment":{"url":"https://api.github.com/repos/square/retrofit/issues/comments/78048884","html_url":"https://github.com/square/retrofit/issues/755#issuecomment-78048884","issue_url":"https://api.github.com/repos/square/retrofit/issues/755","id":78048884,"user":{"login":"deionalims","id":1353452,"avatar_url":"https://avatars.githubusercontent.com/u/1353452?v=3","gravatar_id":"","url":"https://api.github.com/users/deionalims","html_url":"https://github.com/deionalims","followers_url":"https://api.github.com/users/deionalims/followers","following_url":"https://api.github.com/users/deionalims/following{/other_user}","gists_url":"https://api.github.com/users/deionalims/gists{/gist_id}","starred_url":"https://api.github.com/users/deionalims/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deionalims/subscriptions","organizations_url":"https://api.github.com/users/deionalims/orgs","repos_url":"https://api.github.com/users/deionalims/repos","events_url":"https://api.github.com/users/deionalims/events{/privacy}","received_events_url":"https://api.github.com/users/deionalims/received_events","type":"User","site_admin":false},"created_at":"2015-03-10T13:07:10Z","updated_at":"2015-03-10T13:07:10Z","body":"Hello.\r\n\r\nI have the exact same problem. It's on a 204 http response though okio tries to read the body and it ends up as a EOFException. We can easily see that it appears in the logAndReplaceResponse() method. It logs correctly the headers and for some reason it wants to log the body that is empty and it crashes. \r\nI'm out of ideas. Any advice would really help. Thanks."}}