EOFException: source exhausted prematurely
See original GitHub issueI’m always getting java.io.EOFException: source exhausted prematurely when I try a request using OkHttp (2.x, 3.x).
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://www.ddanzi.com")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string().length());
output
java.io.EOFException: source exhausted prematurely
at okio.InflaterSource.read(InflaterSource.java:82)
at okio.GzipSource.read(GzipSource.java:80)
at okio.Buffer.writeAll(Buffer.java:956)
at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:92)
at okhttp3.ResponseBody.bytes(ResponseBody.java:83)
at okhttp3.ResponseBody.string(ResponseBody.java:109)
But if I add an Accept-Encoding header to a request addHeader("Accept-Encoding", "gzip")
there is no problem.
Does anyone know why?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Getting "source exhausted prematurely" when inflating gzip ...
The server data is corrupt. It's supposed to contain a gzip trailer to indicate the end of the stream and that's missing.
Read more >java.io.EOFException: source exhausted prematurely - B4X
EOFException : source exhausted prematurely. i have a server side function (VB.Net) to download the data, had some error but found a solution ......
Read more >Getting "Source Exhausted Prematurely" When ... - ADocLib
I'm getting this error when I try to make a HTTP call with okhttp: W/System.err: java.io.EOFException: source exhausted prematurely W/System.err: at okio.
Read more >okio/src/main/java/okio/InflaterSource.java - Google Git
public final class InflaterSource implements Source { ... if (sourceExhausted) throw new EOFException("source exhausted prematurely");.
Read more >【OkHttp】java.io.EOFException: source exhausted prematurely
GCPのError Reportingで以下のエラーが検知されていた java.io.EOFException: source exhausted prematurely AppEngineがある外部サービスのAPI ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually bytes+headers would be awesome since we could repro in a unit test, in theory. Do you have a payload that doesn’t contain anything secret? Or can your server engs set up an example one that you can capture the raw bytes from?
On Wed, Nov 15, 2017, 7:43 PM Eric Denman notifications@github.com wrote:
I’m having the same problem. Here are the logged request and response:
request:
Response:
Content-Length is the correct length for response body. What else could cause this? Our server works fine with the web and iOS ends