
okhttp2.gif
RetryAndFollowUpInterceptor創(chuàng)建StreamAllocation對(duì)象,處理http的重定向及出錯(cuò)重試。對(duì)后續(xù)Interceptor的執(zhí)行的影響為修改Request并創(chuàng)建StreamAllocation對(duì)象。
BridgeInterceptor補(bǔ)全缺失的一些http header。對(duì)后續(xù)Interceptor的執(zhí)行的影響主要為修改了Request。
Connection:keep-alive這里被默認(rèn)添加CacheInterceptor處理http緩存。對(duì)后續(xù)Interceptor的執(zhí)行的影響為,若緩存中有所需請(qǐng)求的響應(yīng),則后續(xù)Interceptor不再執(zhí)行。
ConnectInterceptor借助于前面分配的StreamAllocation對(duì)象建立與服務(wù)器之間的連接,并選定交互所用的協(xié)議是HTTP 1.1還是HTTP 2。對(duì)后續(xù)Interceptor的執(zhí)行的影響為,創(chuàng)建了HttpStream和connection。
CallServerInterceptor作為Interceptor鏈中的最后一個(gè)Interceptor,用于處理IO,與服務(wù)器進(jìn)行數(shù)據(jù)交換。
http://m.itdecent.cn/p/5c98999bc34f