Class HttpClientBuilder
- java.lang.Object
-
- net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder
-
- Direct Known Subclasses:
FileCachingHttpClientBuilder,InMemoryCachingHttpClientBuilder
public class HttpClientBuilder extends Object
Builder used to constructHttpClientobjects 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 which are set as the default instance on the Apache builder will be unconditionally
overwritten by this builder when
buildClient()is called:RequestConfigConnectionConfig
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 default request or connection config parameters which are not exposed by this builder, then you must use the Apache builder directly and may not use this builder.
-
If this builder's
connectionDisregardTLSCertificateis set totrue, then any value previously set via the Apache builder'sHttpClientBuilder.setSSLSocketFactory(org.apache.http.conn.socket.LayeredConnectionSocketFactory)will be unconditionally overwritten. -
If this builder is supplied with a
connectionProxyHost,connectionProxyUsernameandconnectionProxyPassword, then any value previously set via the Apache builder'sHttpClientBuilder.setDefaultCredentialsProvider(CredentialsProvider)will be unconditionally overwritten. -
Per the Apache builder's Javadoc, if a non-null instance of
HttpClientConnectionManageris set on the Apache builder viaHttpClientBuilder.setConnectionManager(org.apache.http.conn.HttpClientConnectionManager), this supersedes various other properties set on the Apache builder. This includes the following instances/properties on the Apache builder:SSLSocketFactory(LayeredConnectionSocketFactory)SSLContextHostnameVerifierSocketConfigConnectionConfigmaxConnTotalmaxConnPerRoute
Similarly, the following setters on this builder will become ineffective when a non-null connection manger is set on the Apache builder:
setTLSSocketFactory(LayeredConnectionSocketFactory)setConnectionDisregardTLSCertificate(boolean)setSocketBufferSize(int)setHttpContentCharSet(String)setMaxConnectionsTotal(int)setMaxConnectionsPerRoute(int)
Therefore, if you need to explicitly supply a connection manager instance to the Apache builder (for example in order to be able to use
IdleConnectionSweeper), then you must supply these properties or instances directly to the connection manager rather than to this builder or the Apache builder. -
Similar to the above issue, setting an explicit
SSLSocketFactoryon the Apache builder will supersede the following Apache builder properties:
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.http.impl.client.HttpClientBuilderapacheBuilderThe Apache HttpClientBuilder 4.3+ instance over which to layer this builder.private booleanconnectionCloseAfterResponseWhether to instruct the server to close the connection after it has sent its response.private booleanconnectionDisregardTLSCertificateWhether the SSL/TLS certificates used by the responder should be ignored.private StringconnectionProxyHostHost name of the HTTP proxy server through which connections will be made.private StringconnectionProxyPasswordPassword used to connect to the HTTP proxy server.private intconnectionProxyPortPort number of the HTTP proxy server through which connections will be made.private StringconnectionProxyUsernameUsername used to connect to the HTTP proxy server.private DurationconnectionRequestTimeoutMaximum length of time to wait for a connection to be returned from the connection manager.private booleanconnectionStaleCheckWhether to check a connection for staleness before using.private DurationconnectionTimeoutMaximum length of time to wait for the connection to be established.private booleandisableAuthCachingFlag for disabling auth caching.private booleandisableAutomaticRetriesFlag for disabling automatic retries.private booleandisableConnectionStateFlag for disabling connection state.private booleandisableContentCompressionFlag for disabling content compression.private booleandisableCookieManagementFlag for disabling cookie management.private booleandisableRedirectHandlingFlag for disabling redirect handling.private StringhttpContentCharSetCharacter set used for HTTP entity content.private booleanhttpFollowRedirectsWhether to follow HTTP redirects.private intmaxConnectionsPerRouteMax simultaneous connections per route allowed by the pooling connection manager.private intmaxConnectionsTotalMax total simultaneous connections allowed by the pooling connection manager.private List<org.apache.http.HttpRequestInterceptor>requestInterceptorsFirstList of request interceptors to add first.private List<org.apache.http.HttpRequestInterceptor>requestInterceptorsLastList of request interceptors to add last.private List<org.apache.http.HttpResponseInterceptor>responseInterceptorsFirstList of response interceptors to add first.private List<org.apache.http.HttpResponseInterceptor>responseInterceptorsLastList of response interceptors to add last.private org.apache.http.client.HttpRequestRetryHandlerretryHandlerHandler which determines if a request should be retried after a recoverable exception during execution.private org.apache.http.client.ServiceUnavailableRetryStrategyserviceUnavailStrategyStrategy which determines if a request should be retried given the response from the target server.private intsocketBufferSizeSocket buffer size in bytes.private InetAddresssocketLocalAddressLocal IP address used when establishing connections.private DurationsocketTimeoutMaximum period inactivity between two consecutive data packets.private List<HttpClientContextHandler>staticContextHandlersList of static context handlers.private org.apache.http.conn.socket.LayeredConnectionSocketFactorytlsSocketFactoryThe TLS socket factory to use.private StringuserAgentApache UserAgent.private booleanuseSystemPropertiesFlag for enabling use of system properties.
-
Constructor Summary
Constructors Constructor Description HttpClientBuilder()Constructor.HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder builder)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.apache.http.client.HttpClientbuildClient()Constructs anHttpClientusing the settings of this builder.protected voiddecorateApacheBuilder()Decorate the Apache builder as determined by this builder's parameters.protected org.apache.http.impl.client.HttpClientBuildergetApacheBuilder()Get the ApacheHttpClientBuilderinstance over which this builder will be layered.StringgetConnectionProxyHost()Gets the hostname of the default proxy used when making connection.StringgetConnectionProxyPassword()Gets the password used when authenticating to the proxy.intgetConnectionProxyPort()Gets the port of the default proxy used when making connection.StringgetConnectionProxyUsername()Gets the username to use when authenticating to the proxy.DurationgetConnectionRequestTimeout()Gets the maximum length of time to wait for a connection to be returned from the connection manager.DurationgetConnectionTimeout()Gets the maximum length of time to wait for the connection to be established.List<org.apache.http.HttpRequestInterceptor>getFirstRequestInterceptors()Get the list of request interceptors to add first.List<org.apache.http.HttpResponseInterceptor>getFirstResponseInterceptors()Get the list of response interceptors to add first.StringgetHttpContentCharSet()Gets the character set used with the HTTP entity (body).org.apache.http.client.HttpRequestRetryHandlergetHttpRequestRetryHandler()Get the handler which determines if a request should be retried after a recoverable exception during execution.List<org.apache.http.HttpRequestInterceptor>getLastRequestInterceptors()Get the list of request interceptors to add last.List<org.apache.http.HttpResponseInterceptor>getLastResponseInterceptors()Get the list of response interceptors to add last.intgetMaxConnectionsPerRoute()Gets the max simultaneous connections per route allowed by the pooling connection manager.intgetMaxConnectionsTotal()Gets the max total simultaneous connections allowed by the pooling connection manager.org.apache.http.client.ServiceUnavailableRetryStrategygetServiceUnavailableRetryHandler()Get the handler which determines if a request should be retried given the response from the target server.intgetSocketBufferSize()Gets the size of the socket buffer, in bytes, used for request/response buffering.InetAddressgetSocketLocalAddress()Gets the local IP address used when making requests.DurationgetSocketTimeout()Gets the maximum period inactivity between two consecutive data packets.List<HttpClientContextHandler>getStaticContextHandlers()Get the list of staticHttpClientContextHandler.org.apache.http.conn.socket.LayeredConnectionSocketFactorygetTLSSocketFactory()Get the TLS socket factory to use.StringgetUserAgent()Gets user agent.booleanisConnectionCloseAfterResponse()Gets whether to instruct the server to close the connection after it has sent its response.booleanisConnectionDisregardTLSCertificate()Gets whether the responder's SSL/TLS certificate should be ignored.booleanisConnectionStalecheck()Deprecated, for removal: This API element is subject to removal in a future version.booleanisConnectionStaleCheck()Deprecated, for removal: This API element is subject to removal in a future version.use a custom-configured connection pool manger.booleanisDisableAuthCaching()Get the flag for disabling auth caching.booleanisDisableAutomaticRetries()Get the flag for disabling automatic retries.booleanisDisableConnectionState()Get the flag for disabling connection state.booleanisDisableContentCompression()Get the flag for disabling content compression.booleanisDisableCookieManagement()Get the flag for disabling cookie management.booleanisDisableRedirectHandling()Get the flag for disabling redirect handling.booleanisHttpFollowRedirects()Gets whether HTTP redirects will be followed.booleanisUseSystemProperties()Get the flag enabling use of system properties.voidresetDefaults()Resets all builder parameters to their defaults.voidsetConnectionCloseAfterResponse(boolean close)Sets whether to instruct the server to close the connection after it has sent its response.voidsetConnectionDisregardTLSCertificate(boolean disregard)Sets whether the responder's SSL/TLS certificate should be ignored.voidsetConnectionProxyHost(String host)Sets the hostname of the default proxy used when making connection.voidsetConnectionProxyPassword(String password)Sets the password used when authenticating to the proxy.voidsetConnectionProxyPort(int port)Sets the port of the default proxy used when making connection.voidsetConnectionProxyUsername(String usename)Sets the username to use when authenticating to the proxy.voidsetConnectionRequestTimeout(Duration timeout)Sets the maximum length of time to wait for a connection to be returned from the connection manager.voidsetConnectionStalecheck(boolean check)Deprecated, for removal: This API element is subject to removal in a future version.voidsetConnectionStaleCheck(boolean check)Deprecated, for removal: This API element is subject to removal in a future version.use a custom-configured connection pool manger.voidsetConnectionTimeout(Duration timeout)Sets the maximum length of time to wait for the connection to be established.voidsetDisableAuthCaching(boolean flag)Set the flag for disabling auth caching.voidsetDisableAutomaticRetries(boolean flag)Set the flag for disabling automatic retries.voidsetDisableConnectionState(boolean flag)Set the flag for disabling connection state.voidsetDisableContentCompression(boolean flag)Set the flag for disabling content compression.voidsetDisableCookieManagement(boolean flag)Set the flag for disabling cookie management.voidsetDisableRedirectHandling(boolean flag)Set the flag for disabling redirect handling.voidsetFirstRequestInterceptors(List<org.apache.http.HttpRequestInterceptor> interceptors)Set the list of request interceptors to add first.voidsetFirstResponseInterceptors(List<org.apache.http.HttpResponseInterceptor> interceptors)Set the list of response interceptors to add first.voidsetHttpContentCharSet(String charSet)Sets the character set used with the HTTP entity (body).voidsetHttpFollowRedirects(boolean followRedirects)Gets whether HTTP redirects will be followed.voidsetHttpRequestRetryHandler(org.apache.http.client.HttpRequestRetryHandler handler)Set the handler which determines if a request should be retried after a recoverable exception during execution.voidsetLastRequestInterceptors(List<org.apache.http.HttpRequestInterceptor> interceptors)Set the list of request interceptors to add last.voidsetLastResponseInterceptors(List<org.apache.http.HttpResponseInterceptor> interceptors)Set the list of response interceptors to add last.voidsetMaxConnectionsPerRoute(int max)Sets the max simultaneous connections per route allowed by the pooling connection manager.voidsetMaxConnectionsTotal(int max)Sets the max total simultaneous connections allowed by the pooling connection manager.voidsetServiceUnavailableRetryHandler(org.apache.http.client.ServiceUnavailableRetryStrategy strategy)Set the strategy which determines if a request should be retried given the response from the target server.voidsetSocketBufferSize(int size)Sets size of the socket buffer, in bytes, used for request/response buffering.voidsetSocketLocalAddress(String ipOrHost)Sets the local IP address used when making requests.voidsetSocketLocalAddress(InetAddress address)Sets the local IP address used when making requests.voidsetSocketTimeout(Duration timeout)Sets the maximum period inactivity between two consecutive data packets.voidsetStaticContextHandlers(List<HttpClientContextHandler> handlers)Set the list of staticHttpClientContextHandler.voidsetTLSSocketFactory(org.apache.http.conn.socket.LayeredConnectionSocketFactory factory)Set the TLS socket factory to use.voidsetUserAgent(String what)Sets user agent.voidsetUseSystemProperties(boolean flag)Set the flag enabling use of system properties.
-
-
-
Field Detail
-
socketLocalAddress
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);
-
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.http.conn.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
-
connectionStaleCheck
private boolean connectionStaleCheck
Whether to check a connection for staleness before using. This can be an expensive operation. Default value: false
-
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
-
retryHandler
@Nullable private org.apache.http.client.HttpRequestRetryHandler retryHandler
Handler which determines if a request should be retried after a recoverable exception during execution.
-
serviceUnavailStrategy
@Nullable private org.apache.http.client.ServiceUnavailableRetryStrategy serviceUnavailStrategy
Strategy which determines if a request should be retried given the response from the target server.
-
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.
-
requestInterceptorsFirst
@Nonnull @NonnullElements @Unmodifiable @NotLive private List<org.apache.http.HttpRequestInterceptor> requestInterceptorsFirst
List of request interceptors to add first.
-
requestInterceptorsLast
@Nonnull @NonnullElements @Unmodifiable @NotLive private List<org.apache.http.HttpRequestInterceptor> requestInterceptorsLast
List of request interceptors to add last.
-
responseInterceptorsFirst
@Nonnull @NonnullElements @Unmodifiable @NotLive private List<org.apache.http.HttpResponseInterceptor> responseInterceptorsFirst
List of response interceptors to add first.
-
responseInterceptorsLast
@Nonnull @NonnullElements @Unmodifiable @NotLive private List<org.apache.http.HttpResponseInterceptor> responseInterceptorsLast
List of response interceptors to add last.
-
staticContextHandlers
@Nonnull @NonnullElements @Unmodifiable @NotLive private List<HttpClientContextHandler> staticContextHandlers
List of static context handlers.
-
apacheBuilder
private org.apache.http.impl.client.HttpClientBuilder apacheBuilder
The Apache HttpClientBuilder 4.3+ instance over which to layer this builder.
-
-
Method Detail
-
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
-
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.http.conn.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.http.conn.socket.LayeredConnectionSocketFactory).- Parameters:
disregard- whether the responder's SSL/TLS certificate should be ignored
-
getTLSSocketFactory
@Nullable public org.apache.http.conn.socket.LayeredConnectionSocketFactory getTLSSocketFactory()
Get the TLS socket factory to use.- Returns:
- the socket factory, or null.
-
setTLSSocketFactory
public void setTLSSocketFactory(@Nullable org.apache.http.conn.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
-
isConnectionStalecheck
@Deprecated(forRemoval=true) public boolean isConnectionStalecheck()
Deprecated, for removal: This API element is subject to removal in a future version.Gets whether reused connections are checked if they are closed before being used by the client.- Returns:
- whether reused connections are checked if they are closed before being used by the client
-
setConnectionStalecheck
@Deprecated(forRemoval=true) public void setConnectionStalecheck(boolean check)
Deprecated, for removal: This API element is subject to removal in a future version.Sets whether reused connections are checked if they are closed before being used by the client. Checking can take up to 30ms (per request). If checking is turned off an I/O error occurs if the connection is used request. This should be enabled uncles the code using the client explicitly handles the error case and retries connection as appropriate.- Parameters:
check- whether reused connections are checked if they are closed before being used by the client
-
isConnectionStaleCheck
@Deprecated(forRemoval=true) public boolean isConnectionStaleCheck()
Deprecated, for removal: This API element is subject to removal in a future version.use a custom-configured connection pool manger. SeePoolingHttpClientConnectionManager.setValidateAfterInactivity(int)Gets whether reused connections are checked if they are closed before being used by the client.- Returns:
- whether reused connections are checked if they are closed before being used by the client
-
setConnectionStaleCheck
@Deprecated(forRemoval=true) public void setConnectionStaleCheck(boolean check)
Deprecated, for removal: This API element is subject to removal in a future version.use a custom-configured connection pool manger. SeePoolingHttpClientConnectionManager.setValidateAfterInactivity(int)Sets whether reused connections are checked if they are closed before being used by the client. Checking can take up to 30ms (per request). If checking is turned off an I/O error occurs if the connection is used request. This should be enabled uncles the code using the client explicitly handles the error case and retries connection as appropriate.- Parameters:
check- whether reused connections are checked if they are closed before being used by the client
-
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.
-
getHttpRequestRetryHandler
@Nullable public org.apache.http.client.HttpRequestRetryHandler getHttpRequestRetryHandler()
Get the handler which determines if a request should be retried after a recoverable exception during execution.- Returns:
- handler which determines if a request should be retried
-
setHttpRequestRetryHandler
public void setHttpRequestRetryHandler(@Nullable org.apache.http.client.HttpRequestRetryHandler handler)Set the handler which determines if a request should be retried after a recoverable exception during execution.- Parameters:
handler- handler which determines if a request should be retried
-
getServiceUnavailableRetryHandler
@Nullable public org.apache.http.client.ServiceUnavailableRetryStrategy getServiceUnavailableRetryHandler()
Get the handler which determines if a request should be retried given the response from the target server.- Returns:
- handler which determines if a request should be retried
-
setServiceUnavailableRetryHandler
public void setServiceUnavailableRetryHandler(@Nullable org.apache.http.client.ServiceUnavailableRetryStrategy strategy)Set the strategy which determines if a request should be retried given the response from the target server.- Parameters:
strategy- handler which determines if a request should be retried
-
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
-
getFirstRequestInterceptors
@Nonnull @NonnullElements @NotLive @Unmodifiable public List<org.apache.http.HttpRequestInterceptor> getFirstRequestInterceptors()
Get the list of request interceptors to add first.- Returns:
- the list of interceptors
-
setFirstRequestInterceptors
public void setFirstRequestInterceptors(@Nullable @NonnullElements List<org.apache.http.HttpRequestInterceptor> interceptors)
Set the list of request interceptors to add first.- Parameters:
interceptors- the list of interceptors, may be null
-
getLastRequestInterceptors
@Nonnull @NonnullElements @NotLive @Unmodifiable public List<org.apache.http.HttpRequestInterceptor> getLastRequestInterceptors()
Get the list of request interceptors to add last.- Returns:
- the list of interceptors
-
setLastRequestInterceptors
public void setLastRequestInterceptors(@Nullable @NonnullElements List<org.apache.http.HttpRequestInterceptor> interceptors)
Set the list of request interceptors to add last.- Parameters:
interceptors- the list of interceptors, may be null
-
getFirstResponseInterceptors
@Nonnull @NonnullElements @NotLive @Unmodifiable public List<org.apache.http.HttpResponseInterceptor> getFirstResponseInterceptors()
Get the list of response interceptors to add first.- Returns:
- the list of interceptors
-
setFirstResponseInterceptors
public void setFirstResponseInterceptors(@Nullable @NonnullElements List<org.apache.http.HttpResponseInterceptor> interceptors)
Set the list of response interceptors to add first.- Parameters:
interceptors- the list of interceptors, may be null
-
getLastResponseInterceptors
@Nonnull @NonnullElements @NotLive @Unmodifiable public List<org.apache.http.HttpResponseInterceptor> getLastResponseInterceptors()
Get the list of response interceptors to add last.- Returns:
- the list of interceptors
-
setLastResponseInterceptors
public void setLastResponseInterceptors(@Nullable @NonnullElements List<org.apache.http.HttpResponseInterceptor> interceptors)
Set the list of response interceptors to add last.- Parameters:
interceptors- the list of interceptors, may be null
-
getStaticContextHandlers
@Nonnull @NonnullElements @NotLive @Unmodifiable public List<HttpClientContextHandler> getStaticContextHandlers()
Get the list of staticHttpClientContextHandler.- Returns:
- the list of handlers
-
setStaticContextHandlers
public void setStaticContextHandlers(@Nullable @NonnullElements List<HttpClientContextHandler> handlers)
Set the list of staticHttpClientContextHandler.- Parameters:
handlers- the list of handlers, may be null
-
buildClient
public org.apache.http.client.HttpClient buildClient() throws ExceptionConstructs anHttpClientusing 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 ExceptionDecorate 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
-
getApacheBuilder
protected org.apache.http.impl.client.HttpClientBuilder getApacheBuilder()
Get the ApacheHttpClientBuilderinstance over which this builder will be layered. Subclasses may override to return a specialized subclass.- Returns:
- the Apache HttpClientBuilder instance to use
-
-