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