【发布时间】:2016-03-31 02:46:35
【问题描述】:
我有来自 Square 的 OkHttpClient 2.7 和 HttpLoggingInterceptor 2.7。我创建了返回 json 的“GET”请求,但由于某种原因没有记录响应正文,响应正文的结果仅为“}”。控制台中存在所有其他内容,如标题、内容类型等。
HttpLoggHttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
mHttpClient.interceptors().add(interceptor);
问题应该出在那个字符串中: logger.log(buffer.clone().readString(charset));
--> END GET
<-- HTTP/1.1 200 OK (420ms)
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; odata.metadata=minimal; odata.streaming=true
Expires: -1
Server: Microsoft-IIS/8.5
OData-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 24 Dec 2015 17:51:42 GMT
Content-Length: 2291
OkHttp-Sent-Millis: 1450979490431
OkHttp-Received-Millis: 1450979490851
}
【问题讨论】:
标签: android request retrofit interceptor okhttp