Android上的Volley + OkHttp在状态200响应中给出错误 [英] Volley + OkHttp on Android gives error on status 200 response
问题描述
当我只用Volley发出请求时,一切顺利,我的StringRequest进入onResponse.
When I make my request with only Volley everything goes well and my StringRequest goes to onResponse.
但是当我切换到Volley + Okhttp组合时,我的请求通过了,我收到与以前相同的响应,但是随后收到以下错误消息:
But when I switch to Volley + Okhttp combination, my request goes through, I receive the same response as before but then I get the following error message:
E/Volley﹕ [122319] BasicNetwork.performRequest: Unexpected response code 200 for <my request url>
java.io.IOException: closed
com.android.volley.NetworkError: java.io.IOException: closed
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:182)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114)
Caused by: java.io.IOException: closed
at okio.RealBufferedSource$1.read(RealBufferedSource.java:345)
at java.io.InputStream.read(InputStream.java:162)
at com.android.volley.toolbox.BasicNetwork.entityToBytes(BasicNetwork.java:254)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:130)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114)
我正在使用此 https://gist.github.com/bryanstern/4e8f1cb5a8e14c202750 我的VolHttp OkHttpStack.
Im using this https://gist.github.com/bryanstern/4e8f1cb5a8e14c202750 for my OkHttpStack for Volley.
推荐答案
我没有太多的时间进行调查,但是在使用通过代理(查尔斯)连接的模拟器时遇到了同样的问题.对我来说,当我在没有代理或没有设备的情况下进行测试时,问题就消失了.
I haven't had too much time to investigate but I was running into the same issue when using the emulator connected through a proxy (Charles). For me the problem goes away when I test without a proxy or on device.
这篇关于Android上的Volley + OkHttp在状态200响应中给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!