java.lang.IllegalStateException: closed when trying to access response in onResponse(Response respon

okhttp onResponse(Response respon){}


java.lang.IllegalStateException: closed
 at com.squareup.okhttp.internal.http.HttpConnection$FixedLengthSource.
 read(HttpConnection.java:455)
 at okio.Buffer.writeAll(Buffer.java:594)
 at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:87)
 at com.squareup.okhttp.ResponseBody.bytes(ResponseBody.java:56)
 at com.squareup.okhttp.ResponseBody.string(ResponseBody.java:82)

原因:由于某处两次调用了
response.body().string();导致closed,有且只能调用一次

你可能感兴趣的:(java.lang.IllegalStateException: closed when trying to access response in onResponse(Response respon)