我收到了这个错误
java.io.IOException: Content-Length and stream length disagree
Run Code Online (Sandbox Code Playgroud)
在这行代码上 return response.body().bytes();
这是完整的代码
编辑:在一些谷歌之后,错误的原因来自okhttp lib
if (contentLength != -1L && contentLength != bytes.size.toLong()) {
throw IOException(
"Content-Length ($contentLength) and stream length (${bytes.size}) disagree")
}
Run Code Online (Sandbox Code Playgroud)
但是如何解决这个问题?
编辑:
这是完整的代码:
public class OkHttpHandler extends AsyncTask<Void, Void, byte[]> {
private final String Fetch_URL = "http://justedhak.comlu.com/get-data.php";
ArrayList<Listitem> Listitem;
int resulta;
OkHttpClient httpClient = new OkHttpClient();
String myJSON;
JSONArray peoples = null;
InputStream inputStream = null;
@Override
protected byte[] doInBackground(Void... params) {
Log.d("e", "dddddddddd");
Log.d("e", Fetch_URL);
Request.Builder …Run Code Online (Sandbox Code Playgroud)