okhttp拦截器
RetryAndFollowUpInterceptor
1. 创建streamAllocation
2. 调用proceed 进行网络请求
3. 根据响应结果判断是否重新请求
4. 调用下一个拦截器,对response处理,返回给上一个拦截器
BridgeInterceptor
修饰request,添加请求头
进行网络请求
- 修饰response
CacheInterceptor
- 目的:更快响应
- 使用:.cache(new Cache(new File(“xxx”)))
- DiskLruCache
- 只会缓存get方法
ConnectInterceptor
- 连接池
- 正式开启网络请求
- RealConnection
CallServerInterceptor
1.创建拦截器,放入list
2.创建拦截器链RealInterceptorChain,执行proceed
getResponseWithInterceptorChain
proceed
分发器: