在使用okhttp和retrofit访问网络的时候,今天测出来问题:
java.io.IOException: unexpected end of stream on okhttp3.Address@XXXX
后解决办法如下:
if (Build.VERSION.SDK != null && Build.VERSION.SDK_INT > 13) {
request = request.newBuilder()
.removeHeader("encryptValue")
.addHeader("encryptValue", key)
.addHeader("Connection", "close")
.build();
}
增加关闭连接即可
.addHeader("Connection", "close")