package com.tiger.okhttp;
import android.util.Log;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
public class LogIntercepter implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();//拿到链信息
Log.i("ning","intercept:request ="+request.toString());
Response response = chain.proceed(request);//继续往下传
Log.i("ning","intercept:response ="+response.toString());
return response;
}
}
okHttpClient = new OkHttpClient
.Builder()
.addInterceptor(new LogIntercepter())
.connectTimeout(3, TimeUnit.SECONDS).build();