Package 

Class MobonOkHttpClient.Builder

    • Constructor Detail

      • MobonOkHttpClient.Builder

        MobonOkHttpClient.Builder()
    • Method Detail

      • connectTimeout

         MobonOkHttpClient.Builder connectTimeout(long timeout, TimeUnit unit)

        Sets the default connect timeout for new connections. A value of 0 means no timeout,otherwise values must be between 1 and MAX_VALUE when converted tomilliseconds.

        The connectTimeout is applied when connecting a TCP socket to the target host.The default value is 10 seconds.

      • readTimeout

         MobonOkHttpClient.Builder readTimeout(long timeout, TimeUnit unit)

        Sets the default read timeout for new connections. A value of 0 means no timeout, otherwisevalues must be between 1 and MAX_VALUE when converted to milliseconds.

        The read timeout is applied to both the TCP socket and for individual read IO operationsincluding on Source of the MobonResponse. The default value is 10 seconds.

      • writeTimeout

         MobonOkHttpClient.Builder writeTimeout(long timeout, TimeUnit unit)

        Sets the default write timeout for new connections. A value of 0 means no timeout, otherwisevalues must be between 1 and MAX_VALUE when converted to milliseconds.

        The write timeout is applied for individual write IO operations.The default value is 10 seconds.

      • pingInterval

         MobonOkHttpClient.Builder pingInterval(long interval, TimeUnit unit)

        Sets the interval between HTTP/2 and web socket pings initiated by this client. Use this toautomatically send ping frames until either the connection fails or it is closed. This keepsthe connection alive and may detect connectivity failures.

        If the server does not respond to each ping with a pong within {@code interval}, thisclient will assume that connectivity has been lost. When this happens on a web socket theconnection is canceled and its listener is notified of the failure. When it happens on an HTTP/2 connection the connection is closed and anycalls it is carrying will fail with an IOException.

        The default value of 0 disables client-initiated pings.

      • proxy

         MobonOkHttpClient.Builder proxy(@Nullable() Proxy proxy)

        Sets the HTTP proxy that will be used by connections created by this client. This takesprecedence over proxySelector, which is only honored when this proxy is null (whichit is by default). To disable proxy use completely, call {@code proxy(Proxy.NO_PROXY)}.

      • proxySelector

         MobonOkHttpClient.Builder proxySelector(ProxySelector proxySelector)

        Sets the proxy selection policy to be used if no proxy is specifiedexplicitly. The proxy selector may return multiple proxies; in that case they will be triedin sequence until a successful connection is established.

        If unset, the system-wide default proxy selector willbe used.

      • cookieJar

         MobonOkHttpClient.Builder cookieJar(CookieJar cookieJar)

        Sets the handler that can accept cookies from incoming HTTP responses and provides cookies tooutgoing HTTP requests.

        If unset, no cookies will be accepted nor provided.

      • dns

         MobonOkHttpClient.Builder dns(Dns dns)

        Sets the DNS service used to lookup IP addresses for hostnames.

        If unset, the system-wide default DNS will be used.

      • sslSocketFactory

         MobonOkHttpClient.Builder sslSocketFactory(SSLSocketFactory sslSocketFactory, X509TrustManager trustManager)

        Sets the socket factory and trust manager used to secure HTTPS connections. If unset, thesystem defaults will be used.

        Most applications should not call this method, and instead use the system defaults. Thoseclasses include special optimizations that can be lost if the implementations are decorated.

        If necessary, you can create and configure the defaults yourself with the following code:

           {@code * * TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance( * TrustManagerFactory.getDefaultAlgorithm()); * trustManagerFactory.init((KeyStore) null); * TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); * if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { * throw new IllegalStateException("Unexpected default trust managers:" * + Arrays.toString(trustManagers)); * } * X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; * * SSLContext sslContext = SSLContext.getInstance("TLS"); * sslContext.init(null, new TrustManager[] { trustManager }, null); * SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); * * MobonOkHttpClient client = new MobonOkHttpClient.Builder() * .sslSocketFactory(sslSocketFactory, trustManager) * .build(); * }
      • certificatePinner

         MobonOkHttpClient.Builder certificatePinner(CertificatePinner certificatePinner)

        Sets the certificate pinner that constrains which certificates are trusted. By default HTTPSconnections rely on only the SSL socket factory to establish trust.Pinning certificates avoids the need to trust certificate authorities.

      • authenticator

         MobonOkHttpClient.Builder authenticator(Authenticator authenticator)

        Sets the authenticator used to respond to challenges from origin servers. Use to set the authenticator for proxy servers.

        If unset, the no authentication will be attempted.

      • followSslRedirects

         MobonOkHttpClient.Builder followSslRedirects(boolean followProtocolRedirects)

        Configure this client to follow redirects from HTTPS to HTTP and from HTTP to HTTPS.

        If unset, protocol redirects will be followed. This is different than the built-in {@code * HttpURLConnection}'s default.

      • retryOnConnectionFailure

         MobonOkHttpClient.Builder retryOnConnectionFailure(boolean retryOnConnectionFailure)

        Configure this client to retry or not when a connectivity problem is encountered. By default,this client silently recovers from the following problems:

        • Unreachable IP addresses. If the URL's host has multiple IP addresses,failure to reach any individual IP address doesn't fail the overall mobonRequest. This canincrease availability of multi-homed services.
        • Stale pooled connections. The ConnectionPool reuses socketsto decrease mobonRequest latency, but these connections will occasionally time out.
        • Unreachable proxy servers. A ProxySelector can be used toattempt multiple proxy servers in sequence, eventually falling back to a directconnection.
        Set this to false to avoid retrying requests when doing so is destructive. In this case thecalling application should do its own recovery of connectivity failures.
      • protocols

         MobonOkHttpClient.Builder protocols(List<Protocol> protocols)

        Configure the protocols used by this client to communicate with remote servers. By defaultthis client will prefer the most efficient transport available, falling back to moreubiquitous protocols. Applications should only call this method to avoid specificcompatibility problems, such as web servers that behave incorrectly when HTTP/2 is enabled.

        The following protocols are currently supported:

        This is an evolving set. Future releases include support for transitionalprotocols. The http/1.1 transport will never be dropped.

        If multiple protocols are specified, ALPN will be used tonegotiate a transport. Protocol negotiation is only attempted for HTTPS URLs.

        HTTP_1_0 is not supported in this set. Requests are initiated with {@code * HTTP/1.1}. If the server responds with {@code HTTP/1.0}, that will be exposed by .

        Parameters:
        protocols - the protocols to use, in order of preference.
      • interceptors

         List<Interceptor> interceptors()

        Returns a modifiable list of interceptors that observe the full span of each call: frombefore the connection is established (if any) until after the response source is selected(either the origin server, cache, or both).

      • networkInterceptors

         List<Interceptor> networkInterceptors()

        Returns a modifiable list of interceptors that observe a single network mobonRequest and response.These interceptors must call proceed exactly once: it is an errorfor a network interceptor to short-circuit or repeat a network mobonRequest.