perf:代码调整
This commit is contained in:
@@ -36,11 +36,14 @@ public class OkHttpLogInterceptor implements Interceptor {
|
||||
logApi.setResult(response.code());
|
||||
|
||||
// 如果是json,xml,text,则保存记录
|
||||
if (response.body() != null && StrUtil.containsAll(response.body().contentType().toString(),
|
||||
"json", "xml", "text")) {
|
||||
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
|
||||
logApi.setRespBody(peekBody.string());
|
||||
peekBody.close();
|
||||
if (response.body() != null) {
|
||||
MediaType mediaType = response.body().contentType();
|
||||
String contentType = mediaType == null ? "" : mediaType.toString();
|
||||
if (StrUtil.containsAny(contentType, "json", "xml", "text")) {
|
||||
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
|
||||
logApi.setRespBody(peekBody.string());
|
||||
peekBody.close();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user