okhttp拦截器

​ RetryAndFollowUpInterceptor

  1. 创建streamAllocation
2. 调用proceed 进行网络请求
3. 根据响应结果判断是否重新请求
4. 调用下一个拦截器,对response处理,返回给上一个拦截器

​ BridgeInterceptor

  1. 修饰request,添加请求头

  2. 进行网络请求

  3. 修饰response

​ CacheInterceptor

  1. 目的:更快响应
  2. 使用:.cache(new Cache(new File(“xxx”)))
  3. DiskLruCache
  4. 只会缓存get方法

​ ConnectInterceptor

  1. 连接池
  2. 正式开启网络请求
  3. RealConnection

​ CallServerInterceptor

1.创建拦截器,放入list

2.创建拦截器链RealInterceptorChain,执行proceed

getResponseWithInterceptorChain

proceed

分发器: