Package net.shibboleth.shared.httpclient

# Class HttpClientBuilder

java.lang.Object
net.shibboleth.shared.httpclient.HttpClientBuilder

Direct Known Subclasses:
  `FileCachingHttpClientBuilder`, `HttpClientFactoryBean`, `InMemoryCachingHttpClientBuilder`

public class HttpClientBuilder extends Object
Builder used to construct `HttpClient` objects configured with particular settings.

When using the single-arg constructor variant to wrap an existing instance of `HttpClientBuilder`, there are several caveats of which to be aware:

Instances of the following will be unconditionally overwritten by this builder when `buildClient()` is called:

- `HttpClientConnectionManager` which includes the following sub-components:
  - Default `ConnectionConfig`
  - `HttpConnectionFactory`
  - `LayeredConnectionSocketFactory` used as the `SSLSocketFactory`
- `HttpRoutePlanner`
- Default `RequestConfig`
- Default `CredentialsProvider`

This is due to the unfortunate fact that the Apache builder does not currently provide accessor methods to obtain the default instances currently set on the builder. Therefore, if you need to set any config parameters which are not exposed by this builder, then you must use the Apache builder directly and may not use this builder.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.apache.hc.client5.http.impl.classic.HttpClientBuilder`
`apacheBuilder`
The Apache HttpClientBuilder 4.3+ instance over which to layer this builder.
`private boolean`
`connectionCloseAfterResponse`
Whether to instruct the server to close the connection after it has sent its response.
`private boolean`
`connectionDisregardTLSCertificate`
Whether the SSL/TLS certificates used by the responder should be ignored.
`private Duration`
`connectionMaxIdleTime`
Max idle time allowed for an idle connection before it is evicted.
`private String`
`connectionProxyHost`
Host name of the HTTP proxy server through which connections will be made.
`private String`
`connectionProxyPassword`
Password used to connect to the HTTP proxy server.
`private int`
`connectionProxyPort`
Port number of the HTTP proxy server through which connections will be made.
`private String`
`connectionProxyUsername`
Username used to connect to the HTTP proxy server.
`private Duration`
`connectionRequestTimeout`
Maximum length of time to wait for a connection to be returned from the connection manager.
`private Duration`
`connectionTimeout`
Maximum length of time to wait for the connection to be established.
`private boolean`
`disableAuthCaching`
Flag for disabling auth caching.
`private boolean`
`disableAutomaticRetries`
Flag for disabling automatic retries.
`private boolean`
`disableConnectionState`
Flag for disabling connection state.
`private boolean`
`disableContentCompression`
Flag for disabling content compression.
`private boolean`
`disableCookieManagement`
Flag for disabling cookie management.
`private boolean`
`disableRedirectHandling`
Flag for disabling redirect handling.
`private boolean`
`evictExpiredConnections`
Flag for evicting expired connections from the connection pool using a background thread.
`private boolean`
`evictIdleConnections`
Flag for evicting expired connections from the connection pool using a background thread.
`private String`
`httpContentCharSet`
Character set used for HTTP entity content.
`private boolean`
`httpFollowRedirects`
Whether to follow HTTP redirects.
`private int`
`maxConnectionsPerRoute`
Max simultaneous connections per route allowed by the pooling connection manager.
`private int`
`maxConnectionsTotal`
Max total simultaneous connections allowed by the pooling connection manager.
`private List<org.apache.hc.core5.http.HttpRequestInterceptor>`
`requestInterceptorsFirst`
List of request interceptors to add first.
`private List<org.apache.hc.core5.http.HttpRequestInterceptor>`
`requestInterceptorsLast`
List of request interceptors to add last.
`private Duration`
`requestTimeout`
Maximum allowed length of time for the entire request/response operation to complete.
`private int`
`requestTimeoutCorePoolSize`
Core pool size of the `ScheduledExecutorService` used to implement requestTimeout handling.
`private List<org.apache.hc.core5.http.HttpResponseInterceptor>`
`responseInterceptorsFirst`
List of response interceptors to add first.
`private List<org.apache.hc.core5.http.HttpResponseInterceptor>`
`responseInterceptorsLast`
List of response interceptors to add last.
`private Duration`
`responseTimeout`
Determines the timeout until arrival of a response from the opposite endpoint.
`private org.apache.hc.client5.http.HttpRequestRetryStrategy`
`retryStrategy`
Strategy which determines whether and how a retry should be attempted.
`private org.apache.hc.client5.http.SchemePortResolver`
`schemePortResolver`
Resolver for port based on a scheme.
`private int`
`socketBufferSize`
Socket buffer size in bytes.
`private InetAddress`
`socketLocalAddress`
Local IP address used when establishing connections.
`private Duration`
`socketTimeout`
Maximum period inactivity between two consecutive data packets.
`private List<HttpClientContextHandler>`
`staticContextHandlers`
List of static context handlers.
`private org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory`
`tlsSocketFactory`
The TLS socket factory to use.
`private String`
`userAgent`
Apache UserAgent.
`private boolean`
`useSystemProperties`
Flag for enabling use of system properties.
`private Duration`
`validateAfterInactivity`
Sets period after inactivity after which persistent connections must be checked to ensure they are still valid.

## Constructor Summary

Constructors
Constructor
Description
`HttpClientBuilder()`
Constructor.
`HttpClientBuilder(org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`org.apache.hc.client5.http.classic.HttpClient`
`buildClient()`
Constructs an `HttpClient` using the settings of this builder.
`protected org.apache.hc.core5.http.io.HttpConnectionFactory<org.apache.hc.client5.http.io.ManagedHttpClientConnection>`
`buildConnectionFactory()`
Build an instance of `HttpConnectionFactory`.
`protected org.apache.hc.client5.http.io.HttpClientConnectionManager`
`buildConnectionManager()`
Build an instance of `HttpClientConnectionManager`
`protected org.apache.hc.client5.http.config.ConnectionConfig`
`buildDefaultConnectionConfig()`
Build the default instance of `ConnectionConfig`.
`protected org.apache.hc.client5.http.auth.CredentialsProvider`
`buildDefaultCredentialsProvider()`
Build default `CredentialsProvider`.
`protected org.apache.hc.client5.http.config.RequestConfig`
`buildDefaultRequestConfig()`
Build the default instance of `RequestConfig`
`protected org.apache.hc.client5.http.routing.HttpRoutePlanner`
`buildRoutePlanner(org.apache.hc.core5.http.HttpHost proxyHost)`
Build the instance of `HttpRoutePlanner`.
`protected void`
`decorateApacheBuilder()`
Decorate the Apache builder as determined by this builder's parameters.
`(package private) org.apache.hc.client5.http.impl.classic.HttpClientBuilder`
`getApacheBuilder()`
Get the Apache `HttpClientBuilder` instance over which this builder will be layered.
`(package private) Duration`
`getConnectionMaxIdleTime()`
Get the max idle time allowed for an idle connection before it is evicted.
`String`
`getConnectionProxyHost()`
Gets the hostname of the default proxy used when making connection.
`String`
`getConnectionProxyPassword()`
Gets the password used when authenticating to the proxy.
`int`
`getConnectionProxyPort()`
Gets the port of the default proxy used when making connection.
`String`
`getConnectionProxyUsername()`
Gets the username to use when authenticating to the proxy.
`Duration`
`getConnectionRequestTimeout()`
Gets the maximum length of time to wait for a connection to be returned from the connection manager.
`Duration`
`getConnectionTimeout()`
Gets the maximum length of time to wait for the connection to be established.
`List<org.apache.hc.core5.http.HttpRequestInterceptor>`
`getFirstRequestInterceptors()`
Get the list of request interceptors to add first.
`List<org.apache.hc.core5.http.HttpResponseInterceptor>`
`getFirstResponseInterceptors()`
Get the list of response interceptors to add first.
`String`
`getHttpContentCharSet()`
Gets the character set used with the HTTP entity (body).
`org.apache.hc.client5.http.HttpRequestRetryStrategy`
`getHttpRequestRetryStrategy()`
Get the strategy which determines whether and how a retry should be attempted.
`List<org.apache.hc.core5.http.HttpRequestInterceptor>`
`getLastRequestInterceptors()`
Get the list of request interceptors to add last.
`List<org.apache.hc.core5.http.HttpResponseInterceptor>`
`getLastResponseInterceptors()`
Get the list of response interceptors to add last.
`int`
`getMaxConnectionsPerRoute()`
Gets the max simultaneous connections per route allowed by the pooling connection manager.
`int`
`getMaxConnectionsTotal()`
Gets the max total simultaneous connections allowed by the pooling connection manager.
`Duration`
`getRequestTimeout()`
Gets the maximum allowed length of time for the entire request/response operation to complete.
`int`
`getRequestTimeoutCorePoolSize()`
Gets the core pool size of the `ScheduledExecutorService` used to implement requestTimeout handling.
`Duration`
`getResponseTimeout()`
Gets the timeout until arrival of a response from the opposite endpoint.
`org.apache.hc.client5.http.SchemePortResolver`
`getSchemePortResolver()`
Get the resolver for port based on a scheme.
`int`
`getSocketBufferSize()`
Gets the size of the socket buffer, in bytes, used for request/response buffering.
`InetAddress`
`getSocketLocalAddress()`
Gets the local IP address used when making requests.
`Duration`
`getSocketTimeout()`
Gets the maximum period inactivity between two consecutive data packets.
`List<HttpClientContextHandler>`
`getStaticContextHandlers()`
Get the list of static `HttpClientContextHandler`.
`org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory`
`getTLSSocketFactory()`
Get the TLS socket factory to use.
`String`
`getUserAgent()`
Gets user agent.
`(package private) Duration`
`getValidateAfterInactivity()`
Gets period after inactivity after which persistent connections must be checked to ensure they are still valid.
`protected void`
`handleFluentProperties(org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)`
Handle the fluent (non-DI-friendly) builder properties.
`boolean`
`isConnectionCloseAfterResponse()`
Gets whether to instruct the server to close the connection after it has sent its response.
`boolean`
`isConnectionDisregardTLSCertificate()`
Gets whether the responder's SSL/TLS certificate should be ignored.
`boolean`
`isDisableAuthCaching()`
Get the flag for disabling auth caching.
`boolean`
`isDisableAutomaticRetries()`
Get the flag for disabling automatic retries.
`boolean`
`isDisableConnectionState()`
Get the flag for disabling connection state.
`boolean`
`isDisableContentCompression()`
Get the flag for disabling content compression.
`boolean`
`isDisableCookieManagement()`
Get the flag for disabling cookie management.
`boolean`
`isDisableRedirectHandling()`
Get the flag for disabling redirect handling.
`boolean`
`isEvictExpiredConnections()`
Get the flag for evicting expired connections from the connection pool using a background thread.
`boolean`
`isEvictIdleConnections()`
Get the flag for evicting idle connections from the connection pool using a background thread.
`boolean`
`isHttpFollowRedirects()`
Gets whether HTTP redirects will be followed.
`boolean`
`isUseSystemProperties()`
Get the flag enabling use of system properties.
`void`
`resetDefaults()`
Resets all builder parameters to their defaults.
`void`
`setConnectionCloseAfterResponse(boolean close)`
Sets whether to instruct the server to close the connection after it has sent its response.
`void`
`setConnectionDisregardTLSCertificate(boolean disregard)`
Sets whether the responder's SSL/TLS certificate should be ignored.
`void`
`setConnectionMaxIdleTime(Duration duration)`
Set the max idle time allowed for an idle connection before it is evicted.
`void`
`setConnectionProxyHost(String host)`
Sets the hostname of the default proxy used when making connection.
`void`
`setConnectionProxyPassword(String password)`
Sets the password used when authenticating to the proxy.
`void`
`setConnectionProxyPort(int port)`
Sets the port of the default proxy used when making connection.
`void`
`setConnectionProxyUsername(String usename)`
Sets the username to use when authenticating to the proxy.
`void`
`setConnectionRequestTimeout(Duration timeout)`
Sets the maximum length of time to wait for a connection to be returned from the connection manager.
`void`
`setConnectionTimeout(Duration timeout)`
Sets the maximum length of time to wait for the connection to be established.
`void`
`setDisableAuthCaching(boolean flag)`
Set the flag for disabling auth caching.
`void`
`setDisableAutomaticRetries(boolean flag)`
Set the flag for disabling automatic retries.
`void`
`setDisableConnectionState(boolean flag)`
Set the flag for disabling connection state.
`void`
`setDisableContentCompression(boolean flag)`
Set the flag for disabling content compression.
`void`
`setDisableCookieManagement(boolean flag)`
Set the flag for disabling cookie management.
`void`
`setDisableRedirectHandling(boolean flag)`
Set the flag for disabling redirect handling.
`void`
`setEvictExpiredConnections(boolean flag)`
Set the flag for evicting expired connections from the connection pool using a background thread.
`void`
`setEvictIdleConnections(boolean flag)`
Set the flag for evicting idle connections from the connection pool using a background thread.
`void`
`setFirstRequestInterceptors(List<org.apache.hc.core5.http.HttpRequestInterceptor> interceptors)`
Set the list of request interceptors to add first.
`void`
`setFirstResponseInterceptors(List<org.apache.hc.core5.http.HttpResponseInterceptor> interceptors)`
Set the list of response interceptors to add first.
`void`
`setHttpContentCharSet(String charSet)`
Sets the character set used with the HTTP entity (body).
`void`
`setHttpFollowRedirects(boolean followRedirects)`
Gets whether HTTP redirects will be followed.
`void`
`setHttpRequestRetryStrategy(org.apache.hc.client5.http.HttpRequestRetryStrategy strategy)`
Set the strategy which determines whether and how a retry should be attempted.
`void`
`setLastRequestInterceptors(List<org.apache.hc.core5.http.HttpRequestInterceptor> interceptors)`
Set the list of request interceptors to add last.
`void`
`setLastResponseInterceptors(List<org.apache.hc.core5.http.HttpResponseInterceptor> interceptors)`
Set the list of response interceptors to add last.
`void`
`setMaxConnectionsPerRoute(int max)`
Sets the max simultaneous connections per route allowed by the pooling connection manager.
`void`
`setMaxConnectionsTotal(int max)`
Sets the max total simultaneous connections allowed by the pooling connection manager.
`void`
`setRequestTimeout(Duration timeout)`
Sets the maximum allowed length of time for the entire request/response operation to complete.
`void`
`setRequestTimeoutCorePoolSize(int size)`
Sets the core pool size of the `ScheduledExecutorService` used to implement requestTimeout handling.
`void`
`setResponseTimeout(Duration timeout)`
Gets the timeout until arrival of a response from the opposite endpoint.
`void`
`setSchemePortResolver(org.apache.hc.client5.http.SchemePortResolver resolver)`
Set the resolver for port based on a scheme.
`void`
`setSocketBufferSize(int size)`
Sets size of the socket buffer, in bytes, used for request/response buffering.
`void`
`setSocketLocalAddress(String ipOrHost)`
Sets the local IP address used when making requests.
`void`
`setSocketLocalAddress(InetAddress address)`
Sets the local IP address used when making requests.
`void`
`setSocketTimeout(Duration timeout)`
Sets the maximum period inactivity between two consecutive data packets.
`void`
`setStaticContextHandlers(List<HttpClientContextHandler> handlers)`
Set the list of static `HttpClientContextHandler`.
`void`
`setTLSSocketFactory(org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory factory)`
Set the TLS socket factory to use.
`void`
`setUserAgent(String what)`
Sets user agent.
`void`
`setUseSystemProperties(boolean flag)`
Set the flag enabling use of system properties.
`void`
`setValidateAfterInactivity(Duration duration)`
Sets period after inactivity after which persistent connections must be checked to ensure they are still valid.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### socketLocalAddress

@Nullable private InetAddress socketLocalAddress
Local IP address used when establishing connections. Default value: system default local address

### socketTimeout

@Nonnull private Duration socketTimeout
Maximum period inactivity between two consecutive data packets. Default value: (60 seconds)

### socketBufferSize

private int socketBufferSize
Socket buffer size in bytes. Default size is 8192 bytes.

### connectionTimeout

@Nonnull private Duration connectionTimeout
Maximum length of time to wait for the connection to be established. Default value: (60 seconds)

### connectionRequestTimeout

@Nonnull private Duration connectionRequestTimeout
Maximum length of time to wait for a connection to be returned from the connection manager. Default value: (60 seconds);

### responseTimeout

@Nonnull private Duration responseTimeout
Determines the timeout until arrival of a response from the opposite endpoint. Default value: (60 seconds)

### requestTimeout

@Nullable private Duration requestTimeout
Maximum allowed length of time for the entire request/response operation to complete. Default value: null

### requestTimeoutCorePoolSize

private int requestTimeoutCorePoolSize
Core pool size of the `ScheduledExecutorService` used to implement requestTimeout handling. Default value: 20

### maxConnectionsTotal

private int maxConnectionsTotal
Max total simultaneous connections allowed by the pooling connection manager.

### maxConnectionsPerRoute

private int maxConnectionsPerRoute
Max simultaneous connections per route allowed by the pooling connection manager.

### connectionDisregardTLSCertificate

private boolean connectionDisregardTLSCertificate
Whether the SSL/TLS certificates used by the responder should be ignored. Default value: false

### tlsSocketFactory

@Nullable private org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory tlsSocketFactory
The TLS socket factory to use. Optional, defaults to null.

### connectionCloseAfterResponse

private boolean connectionCloseAfterResponse
Whether to instruct the server to close the connection after it has sent its response. Default value: true

### validateAfterInactivity

@Nullable private Duration validateAfterInactivity
Sets period after inactivity after which persistent connections must be checked to ensure they are still valid.

### connectionProxyHost

@Nullable private String connectionProxyHost
Host name of the HTTP proxy server through which connections will be made. Default value: null.

### userAgent

@Nullable private String userAgent
Apache UserAgent.

### connectionProxyPort

private int connectionProxyPort
Port number of the HTTP proxy server through which connections will be made. Default value: 8080.

### connectionProxyUsername

@Nullable private String connectionProxyUsername
Username used to connect to the HTTP proxy server. Default value: null.

### connectionProxyPassword

@Nullable private String connectionProxyPassword
Password used to connect to the HTTP proxy server. Default value: null.

### httpFollowRedirects

private boolean httpFollowRedirects
Whether to follow HTTP redirects. Default value: true

### httpContentCharSet

@Nullable private String httpContentCharSet
Character set used for HTTP entity content. Default value: UTF-8

### retryStrategy

@Nullable private org.apache.hc.client5.http.HttpRequestRetryStrategy retryStrategy
Strategy which determines whether and how a retry should be attempted.

### schemePortResolver

@Nullable private org.apache.hc.client5.http.SchemePortResolver schemePortResolver
Resolver for port based on a scheme.

### disableAuthCaching

private boolean disableAuthCaching
Flag for disabling auth caching.

### disableAutomaticRetries

private boolean disableAutomaticRetries
Flag for disabling automatic retries.

### disableConnectionState

private boolean disableConnectionState
Flag for disabling connection state.

### disableContentCompression

private boolean disableContentCompression
Flag for disabling content compression.

### disableCookieManagement

private boolean disableCookieManagement
Flag for disabling cookie management.

### disableRedirectHandling

private boolean disableRedirectHandling
Flag for disabling redirect handling.

### useSystemProperties

private boolean useSystemProperties
Flag for enabling use of system properties.

### evictExpiredConnections

private boolean evictExpiredConnections
Flag for evicting expired connections from the connection pool using a background thread.

### evictIdleConnections

private boolean evictIdleConnections
Flag for evicting expired connections from the connection pool using a background thread.

### connectionMaxIdleTime

@Nonnull private Duration connectionMaxIdleTime
Max idle time allowed for an idle connection before it is evicted.

### requestInterceptorsFirst

@Nonnull @Unmodifiable @NotLive private List<org.apache.hc.core5.http.HttpRequestInterceptor> requestInterceptorsFirst
List of request interceptors to add first.

### requestInterceptorsLast

@Nonnull @Unmodifiable @NotLive private List<org.apache.hc.core5.http.HttpRequestInterceptor> requestInterceptorsLast
List of request interceptors to add last.

### responseInterceptorsFirst

@Nonnull @Unmodifiable @NotLive private List<org.apache.hc.core5.http.HttpResponseInterceptor> responseInterceptorsFirst
List of response interceptors to add first.

### responseInterceptorsLast

@Nonnull @Unmodifiable @NotLive private List<org.apache.hc.core5.http.HttpResponseInterceptor> responseInterceptorsLast
List of response interceptors to add last.

### staticContextHandlers

@Nonnull @Unmodifiable @NotLive private List<HttpClientContextHandler> staticContextHandlers
List of static context handlers.

### apacheBuilder

@Nonnull private final org.apache.hc.client5.http.impl.classic.HttpClientBuilder apacheBuilder
The Apache HttpClientBuilder 4.3+ instance over which to layer this builder.

## Constructor Details

### HttpClientBuilder

public HttpClientBuilder()
Constructor.

### HttpClientBuilder

public HttpClientBuilder(@Nonnull org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)
Constructor.

Parameters:
  `builder` - the Apache HttpClientBuilder 4.3+ instance over which to layer this builder

## Method Details

### resetDefaults

public void resetDefaults()
Resets all builder parameters to their defaults.

### getMaxConnectionsTotal

public int getMaxConnectionsTotal()
Gets the max total simultaneous connections allowed by the pooling connection manager.

Returns:
  the max total connections

### setMaxConnectionsTotal

public void setMaxConnectionsTotal(int max)
Sets the max total simultaneous connections allowed by the pooling connection manager.

Parameters:
  `max` - the max total connection

### getMaxConnectionsPerRoute

public int getMaxConnectionsPerRoute()
Gets the max simultaneous connections per route allowed by the pooling connection manager.

Returns:
  the max connections per route

### setMaxConnectionsPerRoute

public void setMaxConnectionsPerRoute(int max)
Sets the max simultaneous connections per route allowed by the pooling connection manager.

Parameters:
  `max` - the max connections per route

### getSocketLocalAddress

public InetAddress getSocketLocalAddress()
Gets the local IP address used when making requests.

Returns:
  local IP address used when making requests

### setSocketLocalAddress

public void setSocketLocalAddress(InetAddress address)
Sets the local IP address used when making requests.

Parameters:
  `address` - local IP address used when making requests

### setSocketLocalAddress

public void setSocketLocalAddress(String ipOrHost) throws UnknownHostException
Sets the local IP address used when making requests.

Parameters:
  `ipOrHost` - IP address or hostname, never null
Throws:
  `UnknownHostException` - thrown if the given IP or hostname can not be resolved

### getResponseTimeout

@Nonnull public Duration getResponseTimeout()
Gets the timeout until arrival of a response from the opposite endpoint. A value of zero indicates no timeout.

Returns:
  the response timeout

### setResponseTimeout

public void setResponseTimeout(@Nonnull Duration timeout)
Gets the timeout until arrival of a response from the opposite endpoint. A value of zero indicates no timeout.

Parameters:
  `timeout` - the response timeout

### getRequestTimeout

@Nullable public Duration getRequestTimeout()
Gets the maximum allowed length of time for the entire request/response operation to complete.

A value of null means no statically-configured timeout. A timeout may also be supplied on a per-request basis via `HttpClientContext`. See `HttpClientSupport.addRequestTimeout(HttpClientContext, Duration)`.

Returns:
  the request timeout

### setRequestTimeout

public void setRequestTimeout(@Nullable Duration timeout)
Sets the maximum allowed length of time for the entire request/response operation to complete.

A value of null means no statically-configured timeout. A timeout may also be supplied on a per-request basis via `HttpClientContext`. See `HttpClientSupport.addRequestTimeout(HttpClientContext, Duration)`.

Parameters:
  `timeout` - the request timeout

### getRequestTimeoutCorePoolSize

public int getRequestTimeoutCorePoolSize()
Gets the core pool size of the `ScheduledExecutorService` used to implement requestTimeout handling.

This is the number of threads to keep in the pool, even if they are idle. The total number of threads in the pool is allowed to grow up to `Integer.MAX_VALUE`.

Returns:
  the core pool size

### setRequestTimeoutCorePoolSize

public void setRequestTimeoutCorePoolSize(int size)
Sets the core pool size of the `ScheduledExecutorService` used to implement requestTimeout handling.

This is the number of threads to keep in the pool, even if they are idle. The total number of threads in the pool is allowed to grow up to `Integer.MAX_VALUE`.

Parameters:
  `size` - the core pool size

### getSocketTimeout

@Nonnull public Duration getSocketTimeout()
Gets the maximum period inactivity between two consecutive data packets. A value of less than 1 ms indicates no timeout.

Returns:
  maximum period inactivity between two consecutive data packets

### setSocketTimeout

public void setSocketTimeout(@Nonnull Duration timeout)
Sets the maximum period inactivity between two consecutive data packets. A value of less than 1 ms indicates no timeout.

Parameters:
  `timeout` - maximum period inactivity between two consecutive data packets

### getSocketBufferSize

public int getSocketBufferSize()
Gets the size of the socket buffer, in bytes, used for request/response buffering.

Returns:
  size of the socket buffer, in bytes, used for request/response buffering

### setSocketBufferSize

public void setSocketBufferSize(int size)
Sets size of the socket buffer, in bytes, used for request/response buffering.

Parameters:
  `size` - size of the socket buffer, in bytes, used for request/response buffering; must be greater than 0

### getConnectionTimeout

@Nonnull public Duration getConnectionTimeout()
Gets the maximum length of time to wait for the connection to be established. A value of less than 1 ms indicates no timeout.

Returns:
  maximum length of time to wait for the connection to be established

### setConnectionTimeout

public void setConnectionTimeout(@Nonnull Duration timeout)
Sets the maximum length of time to wait for the connection to be established. A value of less than 1 ms indicates no timeout.

Parameters:
  `timeout` - maximum length of time to wait for the connection to be established

### getConnectionRequestTimeout

@Nonnull public Duration getConnectionRequestTimeout()
Gets the maximum length of time to wait for a connection to be returned from the connection manager. A value of less than 1 ms indicates no timeout.

Returns:
  maximum length of time to wait for the connection to be established

### setConnectionRequestTimeout

public void setConnectionRequestTimeout(@Nonnull Duration timeout)
Sets the maximum length of time to wait for a connection to be returned from the connection manager. A value of less than 1 ms indicates no timeout.

Parameters:
  `timeout` - maximum length of time to wait for the connection to be established

### isConnectionDisregardTLSCertificate

public boolean isConnectionDisregardTLSCertificate()
Gets whether the responder's SSL/TLS certificate should be ignored.

This flag is overridden and ignored if a custom TLS socket factory is specified via `setTLSSocketFactory(org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory)`.

Returns:
  whether the responder's SSL/TLS certificate should be ignored

### setConnectionDisregardTLSCertificate

public void setConnectionDisregardTLSCertificate(boolean disregard)
Sets whether the responder's SSL/TLS certificate should be ignored.

This flag is overridden and ignored if a custom TLS socket factory is specified via `setTLSSocketFactory(org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory)`.

Parameters:
  `disregard` - whether the responder's SSL/TLS certificate should be ignored

### getTLSSocketFactory

@Nullable public org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory getTLSSocketFactory()
Get the TLS socket factory to use.

Returns:
  the socket factory, or null.

### setTLSSocketFactory

public void setTLSSocketFactory(@Nullable org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory factory)
Set the TLS socket factory to use.

Parameters:
  `factory` - the new socket factory, may be null

### isConnectionCloseAfterResponse

public boolean isConnectionCloseAfterResponse()
Gets whether to instruct the server to close the connection after it has sent its response.

Returns:
  whether to instruct the server to close the connection after it has sent its response

### setConnectionCloseAfterResponse

public void setConnectionCloseAfterResponse(boolean close)
Sets whether to instruct the server to close the connection after it has sent its response.

Parameters:
  `close` - whether to instruct the server to close the connection after it has sent its response

### getValidateAfterInactivity

@Nullable Duration getValidateAfterInactivity()
Gets period after inactivity after which persistent connections must be checked to ensure they are still valid.

Returns:
  the duration value

### setValidateAfterInactivity

public void setValidateAfterInactivity(@Nullable Duration duration)
Sets period after inactivity after which persistent connections must be checked to ensure they are still valid.

Parameters:
  `duration` - the duration value

### getConnectionProxyHost

@Nullable public String getConnectionProxyHost()
Gets the hostname of the default proxy used when making connection. A null indicates no default proxy.

Returns:
  hostname of the default proxy used when making connection

### setConnectionProxyHost

public void setConnectionProxyHost(@Nullable String host)
Sets the hostname of the default proxy used when making connection. A null indicates no default proxy.

Parameters:
  `host` - hostname of the default proxy used when making connection

### getConnectionProxyPort

public int getConnectionProxyPort()
Gets the port of the default proxy used when making connection.

Returns:
  port of the default proxy used when making connection

### setConnectionProxyPort

public void setConnectionProxyPort(int port)
Sets the port of the default proxy used when making connection.

Parameters:
  `port` - port of the default proxy used when making connection; must be greater than 0 and less than 65536

### getConnectionProxyUsername

@Nullable public String getConnectionProxyUsername()
Gets the username to use when authenticating to the proxy.

Returns:
  username to use when authenticating to the proxy

### setConnectionProxyUsername

public void setConnectionProxyUsername(@Nullable String usename)
Sets the username to use when authenticating to the proxy.

Parameters:
  `usename` - username to use when authenticating to the proxy; may be null

### getConnectionProxyPassword

@Nullable public String getConnectionProxyPassword()
Gets the password used when authenticating to the proxy.

Returns:
  password used when authenticating to the proxy

### setConnectionProxyPassword

public void setConnectionProxyPassword(@Nullable String password)
Sets the password used when authenticating to the proxy.

Parameters:
  `password` - password used when authenticating to the proxy; may be null

### isHttpFollowRedirects

public boolean isHttpFollowRedirects()
Gets whether HTTP redirects will be followed.

Returns:
  whether HTTP redirects will be followed

### setHttpFollowRedirects

public void setHttpFollowRedirects(boolean followRedirects)
Gets whether HTTP redirects will be followed.

Parameters:
  `followRedirects` - true if redirects are followed, false otherwise

### getHttpContentCharSet

@Nullable public String getHttpContentCharSet()
Gets the character set used with the HTTP entity (body).

Returns:
  character set used with the HTTP entity (body)

### setHttpContentCharSet

public void setHttpContentCharSet(@Nullable String charSet)
Sets the character set used with the HTTP entity (body).

Parameters:
  `charSet` - character set used with the HTTP entity (body)

### getUserAgent

@Nullable public String getUserAgent()
Gets user agent.

Returns:
  The user agent.

### setUserAgent

public void setUserAgent(@Nullable String what)
Sets user agent.

Parameters:
  `what` - what to set. If this is null Apache will use the default.

### getHttpRequestRetryStrategy

@Nullable public org.apache.hc.client5.http.HttpRequestRetryStrategy getHttpRequestRetryStrategy()
Get the strategy which determines whether and how a retry should be attempted.

Returns:
  strategy which determines if a request should be retried

### setHttpRequestRetryStrategy

public void setHttpRequestRetryStrategy(@Nullable org.apache.hc.client5.http.HttpRequestRetryStrategy strategy)
Set the strategy which determines whether and how a retry should be attempted.

Parameters:
  `strategy` - handler which determines if a request should be retried

### getSchemePortResolver

@Nullable public org.apache.hc.client5.http.SchemePortResolver getSchemePortResolver()
Get the resolver for port based on a scheme.

Returns:
  the resolver, or null

### setSchemePortResolver

public void setSchemePortResolver(@Nullable org.apache.hc.client5.http.SchemePortResolver resolver)
Set the resolver for port based on a scheme.

Parameters:
  `resolver` - the resolver, or null

### isDisableAuthCaching

public boolean isDisableAuthCaching()
Get the flag for disabling auth caching.

Returns:
  true if disabled, false if not

### setDisableAuthCaching

public void setDisableAuthCaching(boolean flag)
Set the flag for disabling auth caching.

Parameters:
  `flag` - true if disabled, false if not

### isDisableAutomaticRetries

public boolean isDisableAutomaticRetries()
Get the flag for disabling automatic retries.

Returns:
  true if disabled, false if not

### setDisableAutomaticRetries

public void setDisableAutomaticRetries(boolean flag)
Set the flag for disabling automatic retries.

Parameters:
  `flag` - true if disabled, false if not

### isDisableConnectionState

public boolean isDisableConnectionState()
Get the flag for disabling connection state.

Returns:
  true if disabled, false if not

### setDisableConnectionState

public void setDisableConnectionState(boolean flag)
Set the flag for disabling connection state.

Parameters:
  `flag` - true if disabled, false if not

### isDisableContentCompression

public boolean isDisableContentCompression()
Get the flag for disabling content compression.

Returns:
  true if disabled, false if not

### setDisableContentCompression

public void setDisableContentCompression(boolean flag)
Set the flag for disabling content compression.

Parameters:
  `flag` - true if disabled, false if not

### isDisableCookieManagement

public boolean isDisableCookieManagement()
Get the flag for disabling cookie management.

Returns:
  true if disabled, false if not

### setDisableCookieManagement

public void setDisableCookieManagement(boolean flag)
Set the flag for disabling cookie management.

Parameters:
  `flag` - true if disabled, false if not

### isDisableRedirectHandling

public boolean isDisableRedirectHandling()
Get the flag for disabling redirect handling.

Returns:
  true if disabled, false if not

### setDisableRedirectHandling

public void setDisableRedirectHandling(boolean flag)
Set the flag for disabling redirect handling.

Parameters:
  `flag` - true if disabled, false if not

### isUseSystemProperties

public boolean isUseSystemProperties()
Get the flag enabling use of system properties.

Returns:
  true if enabled, false if not

### setUseSystemProperties

public void setUseSystemProperties(boolean flag)
Set the flag enabling use of system properties.

Parameters:
  `flag` - true if enabled, false if not

### isEvictExpiredConnections

public boolean isEvictExpiredConnections()
Get the flag for evicting expired connections from the connection pool using a background thread.

Returns:
  true if enabled, false if not

### setEvictExpiredConnections

public void setEvictExpiredConnections(boolean flag)
Set the flag for evicting expired connections from the connection pool using a background thread.

Parameters:
  `flag` - true if enabled, false if not

### isEvictIdleConnections

public boolean isEvictIdleConnections()
Get the flag for evicting idle connections from the connection pool using a background thread.

Returns:
  true if enabled, false if not

### setEvictIdleConnections

public void setEvictIdleConnections(boolean flag)
Set the flag for evicting idle connections from the connection pool using a background thread.

Parameters:
  `flag` - true if enabled, false if not

### getConnectionMaxIdleTime

@Nonnull Duration getConnectionMaxIdleTime()
Get the max idle time allowed for an idle connection before it is evicted.

Returns:
  max idle time

### setConnectionMaxIdleTime

public void setConnectionMaxIdleTime(@Nonnull Duration duration)
Set the max idle time allowed for an idle connection before it is evicted.

Parameters:
  `duration` - the max idle time

### getFirstRequestInterceptors

@Nonnull @NotLive @Unmodifiable public List<org.apache.hc.core5.http.HttpRequestInterceptor> getFirstRequestInterceptors()
Get the list of request interceptors to add first.

Returns:
  the list of interceptors

### setFirstRequestInterceptors

public void setFirstRequestInterceptors(@Nullable List<org.apache.hc.core5.http.HttpRequestInterceptor> interceptors)
Set the list of request interceptors to add first.

Parameters:
  `interceptors` - the list of interceptors, may be null

### getLastRequestInterceptors

@Nonnull @NotLive @Unmodifiable public List<org.apache.hc.core5.http.HttpRequestInterceptor> getLastRequestInterceptors()
Get the list of request interceptors to add last.

Returns:
  the list of interceptors

### setLastRequestInterceptors

public void setLastRequestInterceptors(@Nullable List<org.apache.hc.core5.http.HttpRequestInterceptor> interceptors)
Set the list of request interceptors to add last.

Parameters:
  `interceptors` - the list of interceptors, may be null

### getFirstResponseInterceptors

@Nonnull @NotLive @Unmodifiable public List<org.apache.hc.core5.http.HttpResponseInterceptor> getFirstResponseInterceptors()
Get the list of response interceptors to add first.

Returns:
  the list of interceptors

### setFirstResponseInterceptors

public void setFirstResponseInterceptors(@Nullable List<org.apache.hc.core5.http.HttpResponseInterceptor> interceptors)
Set the list of response interceptors to add first.

Parameters:
  `interceptors` - the list of interceptors, may be null

### getLastResponseInterceptors

@Nonnull @NotLive @Unmodifiable public List<org.apache.hc.core5.http.HttpResponseInterceptor> getLastResponseInterceptors()
Get the list of response interceptors to add last.

Returns:
  the list of interceptors

### setLastResponseInterceptors

public void setLastResponseInterceptors(@Nullable List<org.apache.hc.core5.http.HttpResponseInterceptor> interceptors)
Set the list of response interceptors to add last.

Parameters:
  `interceptors` - the list of interceptors, may be null

### getStaticContextHandlers

@Nonnull @NotLive @Unmodifiable public List<HttpClientContextHandler> getStaticContextHandlers()
Get the list of static `HttpClientContextHandler`.

Returns:
  the list of handlers

### setStaticContextHandlers

public void setStaticContextHandlers(@Nullable List<HttpClientContextHandler> handlers)
Set the list of static `HttpClientContextHandler`.

Parameters:
  `handlers` - the list of handlers, may be null

### buildClient

@Nonnull public org.apache.hc.client5.http.classic.HttpClient buildClient() throws Exception
Constructs an `HttpClient` using the settings of this builder.

Returns:
  the constructed client
Throws:
  `Exception` - if there is any problem building the new client instance

### decorateApacheBuilder

protected void decorateApacheBuilder() throws Exception
Decorate the Apache builder as determined by this builder's parameters. Subclasses will likely add additional decoration.

Throws:
  `Exception` - if there is a problem decorating the Apache builder

### buildRoutePlanner

@Nullable protected org.apache.hc.client5.http.routing.HttpRoutePlanner buildRoutePlanner(@Nullable org.apache.hc.core5.http.HttpHost proxyHost)
Build the instance of `HttpRoutePlanner`. This is only necessary if we have a configured local address via (@link `getSocketLocalAddress()`).

Parameters:
  `proxyHost` - the proxy host, or null
Returns:
  the route planner instance, or null

### handleFluentProperties

protected void handleFluentProperties(@Nonnull org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)
Handle the fluent (non-DI-friendly) builder properties.

Parameters:
  `builder` - the Apache HttpClientBuilder

### buildDefaultCredentialsProvider

@Nullable protected org.apache.hc.client5.http.auth.CredentialsProvider buildDefaultCredentialsProvider()
Build default `CredentialsProvider`.

Returns:
  the default credentials provider, or null

### buildDefaultRequestConfig

@Nonnull protected org.apache.hc.client5.http.config.RequestConfig buildDefaultRequestConfig()
Build the default instance of `RequestConfig`

Returns:
  the request config instance

### buildConnectionManager

@Nonnull protected org.apache.hc.client5.http.io.HttpClientConnectionManager buildConnectionManager()
Build an instance of `HttpClientConnectionManager`

Returns:
  the connection manager instance

### buildDefaultConnectionConfig

@Nonnull protected org.apache.hc.client5.http.config.ConnectionConfig buildDefaultConnectionConfig()
Build the default instance of `ConnectionConfig`.

Returns:
  the default connection config instance

### buildConnectionFactory

@Nonnull protected org.apache.hc.core5.http.io.HttpConnectionFactory<org.apache.hc.client5.http.io.ManagedHttpClientConnection> buildConnectionFactory()
Build an instance of `HttpConnectionFactory`.

Returns:
  the connection factory instance

### getApacheBuilder

@Nonnull org.apache.hc.client5.http.impl.classic.HttpClientBuilder getApacheBuilder()
Get the Apache `HttpClientBuilder` instance over which this builder will be layered. Subclasses may override to return a specialized subclass.

Returns:
  the Apache HttpClientBuilder instance to use