0
我试着从我与Android 8(26奥利奥)服务器获取数据,我得到以下错误:使用改装2.3.0改造+ OkHttp - 的ProtocolException
java.net.ProtocolException: unexpected end of stream
IM,OkHttp 3.9.0。奇怪的是,这个错误只发生在API 26奥利奥而不是任何以前的API上,我随机得到这个错误,有时是的,有时不是。由于RxJava调试功能,该错误很短。
编辑:我改变RxJava用一个简单的呼叫“请求”,这是完全错误:
java.net.ProtocolException: unexpected end of stream
at okhttp3.internal.http1.Http1Codec$FixedLengthSource.read(Http1Codec.java:398)
at okio.RealBufferedSource.readAll(RealBufferedSource.java:163)
at retrofit2.Utils.buffer(Utils.java:304)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:204)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:112)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
,我打这个电话是非常标准:
TestInterface api = retrofit.create(TestInterface.class);
Call<List<Post>> call = api.getFeed(0, 0, "9");
call.enqueue(new Callback<List<Post>>() {
@Override
public void onResponse(Call<List<Post>> call, Response<List<Post>> response) {
Log.i(TAG, "[app] onResponse");
}
@Override
public void onFailure(Call<List<Post>> call, Throwable t) {
Log.i(TAG, "[app] onFailure: ", t);
}
});
这些都是我的回应我检查了内容长度并且它与我的回复相匹配:
Allow →GET, HEAD, OPTIONS
Connection →close
Content-Language →en
Content-Length →3277
Content-Type →application/json
Date →Sat, 09 Sep 2017 14:58:38 GMT
Server →gunicorn/19.7.0
Vary →Accept, Accept-Language, Cookie
X-Frame-Options →SAMEORIGIN
感谢会试试吧! – box
不能正常工作.... – box