okhttp / okhttp3 / OkHttpClient / Builder


class Builder


Name Summary
<init> Builder()


Name Summary
addInterceptor fun addInterceptor(interceptor:Interceptor): Builder
fun addInterceptor(block: (chain: Chain) ->Response): Builder
addNetworkInterceptor fun addNetworkInterceptor(interceptor:Interceptor): Builder
fun addNetworkInterceptor(block: (chain: Chain) ->Response): Builder
authenticator Sets the authenticator used to respond to challenges from origin servers. Use proxyAuthenticator to set the authenticator for proxy servers.fun authenticator(authenticator:Authenticator): Builder
build fun build():OkHttpClient
cache Sets the response cache to be used to read and write cached responses.fun cache(cache:Cache?): Builder
callTimeout Sets the default timeout for complete calls. A value of 0 means no timeout, otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds.fun callTimeout(timeout:Long, unit:TimeUnit): Builder
fun callTimeout(duration:Duration): Builder
certificatePinner Sets the certificate pinner that constrains which certificates are trusted. By default HTTPS connections rely on only the SSL socket factory to establish trust. Pinning certificates avoids the need to trust certificate authorities.fun certificatePinner(certificatePinner:CertificatePinner): Builder
connectionPool Sets the connection pool used to recycle HTTP and HTTPS connections.fun connectionPool(connectionPool:ConnectionPool): Builder
connectionSpecs fun connectionSpecs(connectionSpecs:List<ConnectionSpec>): Builder
connectTimeout Sets the default connect timeout for new connections. A value of 0 means no timeout, otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds.fun connectTimeout(timeout:Long, unit:TimeUnit): Builder
fun connectTimeout(duration:Duration): Builder
cookieJar Sets the handler that can accept cookies from incoming HTTP responses and provides cookies to outgoing HTTP requests.fun cookieJar(cookieJar:CookieJar): Builder
dispatcher Sets the dispatcher used to set policy and execute asynchronous requests. Must not be null.fun dispatcher(dispatcher:Dispatcher): Builder
dns Sets the DNS service used to lookup IP addresses for hostnames.fun dns(dns:Dns): Builder
eventListener Configure a single client scoped listener that will receive all analytic events for this client.fun eventListener(eventListener:EventListener): Builder
eventListenerFactory Configure a factory to provide per-call scoped listeners that will receive analytic events for this client.fun eventListenerFactory(eventListenerFactory: Factory): Builder
followRedirects Configure this client to follow redirects. If unset, redirects will be followed.fun followRedirects(followRedirects:Boolean): Builder
followSslRedirects Configure this client to allow protocol redirects from HTTPS to HTTP and from HTTP to HTTPS. Redirects are still first restricted by followRedirects. Defaults to true.fun followSslRedirects(followProtocolRedirects:Boolean): Builder
hostnameVerifier Sets the verifier used to confirm that response certificates apply to requested hostnames for HTTPS connections.fun hostnameVerifier(hostnameVerifier:HostnameVerifier): Builder
interceptors Returns a modifiable list of interceptors that observe the full span of each call: from before the connection is established (if any) until after the response source is selected (either the origin server, cache, or both).fun interceptors():MutableList<Interceptor>
minWebSocketMessageToCompress Sets minimum outbound web socket message size (in bytes) that will be compressed.fun minWebSocketMessageToCompress(bytes:Long): Builder
networkInterceptors Returns a modifiable list of interceptors that observe a single network request and response. These interceptors must call Interceptor.Chain.proceed exactly once: it is an error for a network interceptor to short-circuit or repeat a network request.fun networkInterceptors():MutableList<Interceptor>
pingInterval Sets the interval between HTTP/2 and web socket pings initiated by this client. Use this to automatically send ping frames until either the connection fails or it is closed. This keeps the connection alive and may detect connectivity failures.fun pingInterval(interval:Long, unit:TimeUnit): Builder
fun pingInterval(duration:Duration): Builder
protocols Configure the protocols used by this client to communicate with remote servers. By default this client will prefer the most efficient transport available, falling back to more ubiquitous protocols. Applications should only call this method to avoid specific compatibility problems, such as web servers that behave incorrectly when HTTP/2 is enabled.fun protocols(protocols:List<Protocol>): Builder
proxy Sets the HTTP proxy that will be used by connections created by this client. This takes precedence over proxySelector, which is only honored when this proxy is null (which it is by default). To disable proxy use completely, call proxy(Proxy.NO_PROXY).fun proxy(proxy:Proxy?): Builder
proxyAuthenticator Sets the authenticator used to respond to challenges from proxy servers. Use authenticator to set the authenticator for origin servers.fun proxyAuthenticator(proxyAuthenticator:Authenticator): Builder
proxySelector Sets the proxy selection policy to be used if no proxy is specified explicitly. The proxy selector may return multiple proxies; in that case they will be tried in sequence until a successful connection is established.fun proxySelector(proxySelector:ProxySelector): Builder
readTimeout Sets the default read timeout for new connections. A value of 0 means no timeout, otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds.fun readTimeout(timeout:Long, unit:TimeUnit): Builder
fun readTimeout(duration:Duration): Builder
retryOnConnectionFailure Configure this client to retry or not when a connectivity problem is encountered. By default, this client silently recovers from the following problems:fun retryOnConnectionFailure(retryOnConnectionFailure:Boolean): Builder
socketFactory Sets the socket factory used to create connections. OkHttp only uses the parameterless SocketFactory.createSocket method to create unconnected sockets. Overriding this method, e. g., allows the socket to be bound to a specific local address.fun socketFactory(socketFactory:SocketFactory): Builder
sslSocketFactory Sets the socket factory and trust manager used to secure HTTPS connections. If unset, the system defaults will be used.fun sslSocketFactory(sslSocketFactory:SSLSocketFactory, trustManager:X509TrustManager): Builder
writeTimeout Sets the default write timeout for new connections. A value of 0 means no timeout, otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds.fun writeTimeout(timeout:Long, unit:TimeUnit): Builder
fun writeTimeout(duration:Duration): Builder