0
点赞
收藏
分享

微信扫一扫

【设计模式】责任链模式——责任链模式在OkHttp源码中的应用

OkHttp

List<Interceptor> interceptors = new ArrayList<>();
interceptors.addAll(client.interceptors());
interceptors.add(new RetryAndFollowUpInterceptor(client));
interceptors.add(new BridgeInterceptor(client.cookieJar()));
interceptors.add(new CacheInterceptor(client.internalCache()));
interceptors.add(new ConnectInterceptor(client));
if (!forWebSocket) {
		interceptors.addAll(client.networkInterceptors());
}
interceptors.add(new CallServerInterceptor(forWebSocket));
Interceptor.Chain chain = new RealInterceptorChain(interceptors, transmitter, null, 0,
		originalRequest, this, client.connectTimeoutMillis(),
    client.readTimeoutMillis(), client.writeTimeoutMillis());

OkHttp


自定义拦截器和自定义网络拦截器

自定义拦截器


RetryAndFollowUpInterceptor

RetryAndFollowUpInterceptor


BridgeInterceptor

BridgeInterceptor


CacheInterceptor

CacheInterceptor


ConnectInterceptor

ConnectInterceptor


CallServerInterceptor

CallServerInterceptor

举报

相关推荐

0 条评论