https://blog.csdn.net/qq_37043246/article/details/73293421;

 

public class LoggingInterceptor implements Interceptor {
String TAG = "LoggingInterceptor";

@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Log.v(TAG, "request:" + request.toString());
long t1 = System.nanoTime();
okhttp3.Response response = chain.proceed(chain.request());
long t2 = System.nanoTime();
Log.v(TAG, String.format(Locale.getDefault(), "Received response for %s in %.1fms%n%s", response.request().url(), (t2 - t1) / 1e6d, response.headers()));
okhttp3.MediaType mediaType = response.body().contentType();
String content = response.body().string();
Log.i(TAG, "response body:" + content);
return response.newBuilder().body(okhttp3.ResponseBody.create(mediaType, content)).build();
} // 下面的span没什么用

相关文章:

  • 2022-12-23
  • 2021-11-15
  • 2021-08-30
  • 2021-03-28
  • 2021-10-15
  • 2021-06-21
  • 2021-06-22
猜你喜欢
  • 2022-12-23
  • 2022-01-07
  • 2022-01-07
  • 2022-01-04
相关资源
相似解决方案