我正在使用Retrofit 2.0b2.得到响应后,我尝试从响应中获取一个InputStream:
Response<JsonNode> response = call.execute(); InputStream is = response.raw().body().byteStream();
但应用程序不断投掷:
java.lang.IllegalStateException: Cannot read raw response body of a converted body. at retrofit.OkHttpCall$NoContentResponseBody.source(OkHttpCall.java:184) at com.squareup.okhttp.ResponseBody.byteStream(ResponseBody.java:43) at ...
尽管响应正确返回.我在这里做错了什么?
解决方法
如果你想要原始流,请告诉改装返回一个OkHttp ResponseBody.
Response<ResponseBody> response = call.execute(); InputStream is = response.body().byteStream();
请记住更新您的界面.