OKHttp请求网络的过程就是递归执行每一个拦截器Intercept方法
源码分析:
RealCall.java
Response getResponseWithInterceptorChain() {
...
Chain chain = new RealInterceptorChain(...);
return chain.proceed(this.originalRequest);
}
Response proceed(...){
RealInterceptorChain next = new RealInterceptorChain(.,index+1,..);
Interceptor interceptor = (Interceptor)this.interceptors.get(this.index);
Response response = interceptor.intercept(next);
}
response interceptor.intercept(chain){
...//拦截器功能代码
return chain.proceed //!!!递归质性下一个拦截器,并没有立马返回一个response
}