@get:JvmName("dispatcher") val dispatcher: Dispatcher = builder.dispatcher
//线程调度器,内部提供了一个默认的线程池的构造
@get:JvmName("connectionPool") val connectionPool: ConnectionPool = builder.connectionPool
//连接池,OkHttp可能会有多个连接同时工作,所以建立连接池以复用资源,可以配置连接池,通过重用和自动回收,来追求性能和资源的动态平衡
@get:JvmName("interceptors") val interceptors: List<Interceptor> =builder.interceptors.toImmutableList()
//
@get:JvmName("networkInterceptors") val networkInterceptors: List<Interceptor> =builder.networkInterceptors.toImmutableList()
//
@get:JvmName("eventListenerFactory") val eventListenerFactory: EventListener.Factory =builder.eventListenerFactory
//事件监听器,如连接建立吖,请求发起等
@get:JvmName("retryOnConnectionFailure") val retryOnConnectionFailure: Boolean =builder.retryOnConnectionFailure
//在连接失败时,是否重试(默认true)
@get:JvmName("authenticator") val authenticator: Authenticator =builder.authenticator
//认证修正,如Token过期,重新申请
@get:JvmName("followRedirects") val followRedirects: Boolean =builder.followRedirects
//跟随重定向
@get:JvmName("followSslRedirects") val followSslRedirects: Boolean = =builder.followSslRedirects
//跟随SSL的重定向,意思是切换协议,如http://切换至https://
@get:JvmName("cookieJar") val cookieJar: CookieJar = builder.cookieJar
//cookie罐子,缓存cookie的方法,但是为实现,有需求需要自己实现该方法
@get:JvmName("cache") val cache: Cache? = builder.cache
//本地缓存
@get:JvmName("dns") val dns: Dns = builder.dns
//域名解析用
@get:JvmName("proxy") val proxy: Proxy? = builder.proxy
//代理设置
@get:JvmName("proxySelector") val proxySelector: ProxySelector =
when {
// Defer calls to ProxySelector.getDefault() because it can throw a SecurityException.
builder.proxy != null -> NullProxySelector
else -> builder.proxySelector ?: ProxySelector.getDefault() ?: NullProxySelector
}
@get:JvmName("proxyAuthenticator") val proxyAuthenticator: Authenticator =
builder.proxyAuthenticator
//代理认证修正
@get:JvmName("socketFactory") val socketFactory: SocketFactory = builder.socketFactory
//Socket工厂,Http连接的具体实现是Socket
private val sslSocketFactoryOrNull: SSLSocketFactory?
// SSLSocket工厂,TSL连接用
@get:JvmName("sslSocketFactory") val sslSocketFactory: SSLSocketFactory
get() = sslSocketFactoryOrNull ?: throw IllegalStateException("CLEARTEXT-only client")
@get:JvmName("x509TrustManager") val x509TrustManager: X509TrustManager?
//证书管理器,负责证书认证之类的
@get:JvmName("connectionSpecs") val connectionSpecs: List<ConnectionSpec> =builder.connectionSpecs
//TLS版本和加密套件设置
@get:JvmName("protocols") val protocols: List<Protocol> = builder.protocols
//Http协议版本
@get:JvmName("hostnameVerifier") val hostnameVerifier: HostnameVerifier = builder.hostnameVerifier
@get:JvmName("certificatePinner") val certificatePinner: CertificatePinner
@get:JvmName("certificateChainCleaner") val certificateChainCleaner: CertificateChainCleaner?
//上三都与证书验证相关
@get:JvmName("callTimeoutMillis") val callTimeoutMillis: Int = builder.callTimeout
/** Default connect timeout (in milliseconds). The default is 10 seconds. */
@get:JvmName("connectTimeoutMillis") val connectTimeoutMillis: Int = builder.connectTimeout
/** Default read timeout (in milliseconds). The default is 10 seconds. */
@get:JvmName("readTimeoutMillis") val readTimeoutMillis: Int = builder.readTimeout
/** Default write timeout (in milliseconds). The default is 10 seconds. */
@get:JvmName("writeTimeoutMillis") val writeTimeoutMillis: Int = builder.writeTimeout
/** Web socket and HTTP/2 ping interval (in milliseconds). By default pings are not sent. */
@get:JvmName("pingIntervalMillis") val pingIntervalMillis: Int = builder.pingInterval
//心跳间隔