Class HttpProtocolClientBuilder


  • public class HttpProtocolClientBuilder
    extends Object
    Builds an org.apache.http.client.HttpClient used for making secure API calls over HTTP. Uses TLSv1.2 protocol.
    • Field Detail

      • DEFAULT_CONNECTION_TIMEOUT

        protected static final int DEFAULT_CONNECTION_TIMEOUT
        Intended to be used internally by the SDK.

        The default connection timeout value to establish a connection specified in milliseconds, set to 60 seconds.

        See Also:
        Constant Field Values
      • DEFAULT_CONNECTION_REQUEST_TIMEOUT

        protected static final int DEFAULT_CONNECTION_REQUEST_TIMEOUT
        Intended to be used internally by the SDK.

        The default connection timeout value for requesting a connection from the Apache connection manager specified in milliseconds, set to 60 seconds.

        See Also:
        Constant Field Values
      • DEFAULT_SOCKET_TIMEOUT

        protected static final int DEFAULT_SOCKET_TIMEOUT
        Intended to be used internally by the SDK.

        The default socket timeout value when waiting for data between data packets specified in milliseconds, set to 60 seconds.

        See Also:
        Constant Field Values
      • HDR_USER_AGENT

        protected static final String HDR_USER_AGENT
        The user agent header used for requests from the SDK.
        See Also:
        Constant Field Values
      • HDR_VALUE_USER_AGENT

        protected static final String HDR_VALUE_USER_AGENT
        The value of the user agent header.
        See Also:
        Constant Field Values
      • sslConnectionSocketFactory

        protected org.apache.http.conn.ssl.SSLConnectionSocketFactory sslConnectionSocketFactory
        The Ssl connection socket factory.
      • requestConfigBuilder

        protected org.apache.http.client.config.RequestConfig.Builder requestConfigBuilder
        The Request config builder.
      • defaultHeaders

        protected HashSet<org.apache.http.Header> defaultHeaders
        The default headers. Header values contain PRAGMA and CACHE_CONTROL both set to a "no-cache" option to ensure a fresh version of the resource data.
    • Constructor Detail

      • HttpProtocolClientBuilder

        public HttpProtocolClientBuilder​(Integer connectionTimeout,
                                         Integer connectionRequestTimeout,
                                         Integer socketTimeout)
        Instantiates a new Http client builder service and initializes it with the default configurations for the sslConnectionSocketFactory, and defaultHeaders. Uses the given timeout values to initialize the requestConfigBuilder.

        The timeout params are specified as Integer values, which can be null since Integer is an object. If a given timeout param is null, the corresponding default timeout value will be used in it's place.

        The timeout parameter values are in seconds, and converted to milliseconds when initializing the requestConfigBuilder.

        Parameters:
        connectionTimeout - The timeout in seconds for a connection to be established.
        connectionRequestTimeout - The timeout in seconds when requesting a connection from the Apache connection manager.
        socketTimeout - The timeout in seconds when waiting for data between consecutive data packets.
    • Method Detail

      • doInitialization

        protected void doInitialization​(Integer connectionTimeout,
                                        Integer connectionRequestTimeout,
                                        Integer socketTimeout)
        Intended to be used internally by the SDK.

        Initializes the request config builder, SSL connection socket factory, and the default headers used when building the Http client.

        Parameters:
        connectionTimeout - The timeout in seconds for a connection to be established, or null to use the default value of 60 seconds..
        connectionRequestTimeout - The timeout in seconds when requesting a connection from the Apache connection manager, or null to use the default value of 60 seconds.
        socketTimeout - The timeout in seconds when waiting for data between consecutive data packets, or null to use the default value of 60 seconds.
      • buildHttpClient

        public org.apache.http.client.HttpClient buildHttpClient()
        Builds and returns an HttpClient using the pre-initialized configurations. Each time this method is called a new HttpClient is built and returned.
        Returns:
        HttpClient
      • init

        protected void init​(int connectionTimeout,
                            int connectionRequestTimeout,
                            int socketTimeout)
        Intended to be used internally by the SDK.

        Initialize various configurations used for making HTTP calls. Instantiates the sslConnectionSocketFactory, the requestConfigBuilder, and sets the defaultHeaders.

        Parameters:
        connectionTimeout - The timeout in milliseconds for a connection to be established.
        connectionRequestTimeout - The timeout in milliseconds when requesting a connection from the Apache connection manager.
        socketTimeout - The timeout in milliseconds when waiting for data between consecutive data packets.