@NotThreadSafe public class HttpClientBuilder extends java.lang.Object
CloseableHttpClient
instances.
When a particular component is not explicitly this class will
use its default implementation. System properties will be taken
into account when configuring the default implementations when
useSystemProperties()
method is called prior to calling
build()
.
CloseableHttpClient
instances.Modifier | Constructor and Description |
---|---|
protected |
HttpClientBuilder() |
Modifier and Type | Method and Description |
---|---|
protected void |
addCloseable(java.io.Closeable closeable)
For internal use.
|
HttpClientBuilder |
addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.
|
HttpClientBuilder |
addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.
|
HttpClientBuilder |
addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.
|
HttpClientBuilder |
addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.
|
CloseableHttpClient |
build() |
static HttpClientBuilder |
create() |
protected ClientExecChain |
decorateMainExec(ClientExecChain mainExec)
For internal use.
|
protected ClientExecChain |
decorateProtocolExec(ClientExecChain protocolExec)
For internal use.
|
HttpClientBuilder |
disableAuthCaching()
Disables authentication scheme caching.
|
HttpClientBuilder |
disableAutomaticRetries()
Disables automatic request recovery and re-execution.
|
HttpClientBuilder |
disableConnectionState()
Disables connection state tracking.
|
HttpClientBuilder |
disableContentCompression()
Disables automatic content decompression.
|
HttpClientBuilder |
disableCookieManagement()
Disables state (cookie) management.
|
HttpClientBuilder |
disableRedirectHandling()
Disables automatic redirect handling.
|
HttpClientBuilder |
setBackoffManager(BackoffManager backoffManager)
Assigns
BackoffManager instance. |
HttpClientBuilder |
setConnectionBackoffStrategy(ConnectionBackoffStrategy connectionBackoffStrategy)
Assigns
ConnectionBackoffStrategy instance. |
HttpClientBuilder |
setConnectionManager(HttpClientConnectionManager connManager)
Assigns
HttpClientConnectionManager instance. |
HttpClientBuilder |
setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
Assigns
ConnectionReuseStrategy instance. |
HttpClientBuilder |
setDefaultAuthSchemeRegistry(Lookup<AuthSchemeProvider> authSchemeRegistry)
Assigns default
AuthScheme registry which will
be used for request execution if not explicitly set in the client execution
context. |
HttpClientBuilder |
setDefaultConnectionConfig(ConnectionConfig config)
Assigns default
ConnectionConfig . |
HttpClientBuilder |
setDefaultCookieSpecRegistry(Lookup<CookieSpecProvider> cookieSpecRegistry)
Assigns default
CookieSpec registry which will
be used for request execution if not explicitly set in the client execution
context. |
HttpClientBuilder |
setDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)
Assigns default
CookieStore instance which will be used for
request execution if not explicitly set in the client execution context. |
HttpClientBuilder |
setDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
Assigns default
CredentialsProvider instance which will be used
for request execution if not explicitly set in the client execution
context. |
HttpClientBuilder |
setDefaultHeaders(java.util.Collection<? extends org.apache.http.Header> defaultHeaders)
Assigns default request header values.
|
HttpClientBuilder |
setDefaultRequestConfig(RequestConfig config)
Assigns default
RequestConfig instance which will be used
for request execution if not explicitly set in the client execution
context. |
HttpClientBuilder |
setDefaultSocketConfig(SocketConfig config)
Assigns default
SocketConfig . |
HttpClientBuilder |
setHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)
Assigns
X509HostnameVerifier instance. |
HttpClientBuilder |
setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
Assigns
HttpProcessor instance. |
HttpClientBuilder |
setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
Assigns
ConnectionKeepAliveStrategy instance. |
HttpClientBuilder |
setMaxConnPerRoute(int maxConnPerRoute)
Assigns maximum connection per route value.
|
HttpClientBuilder |
setMaxConnTotal(int maxConnTotal)
Assigns maximum total connection value.
|
HttpClientBuilder |
setProxy(org.apache.http.HttpHost proxy)
Assigns default proxy value.
|
HttpClientBuilder |
setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)
Assigns
AuthenticationStrategy instance for target
host authentication. |
HttpClientBuilder |
setRedirectStrategy(RedirectStrategy redirectStrategy)
Assigns
RedirectStrategy instance. |
HttpClientBuilder |
setRequestExecutor(org.apache.http.protocol.HttpRequestExecutor requestExec)
Assigns
HttpRequestExecutor instance. |
HttpClientBuilder |
setRetryHandler(org.apache.http.client.HttpRequestRetryHandler retryHandler)
Assigns
HttpRequestRetryHandler instance. |
HttpClientBuilder |
setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
Assigns
HttpRoutePlanner instance. |
HttpClientBuilder |
setSchemePortResolver(SchemePortResolver schemePortResolver)
Assigns
SchemePortResolver instance. |
HttpClientBuilder |
setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy serviceUnavailStrategy)
Assigns
ServiceUnavailableRetryStrategy instance. |
HttpClientBuilder |
setSslcontext(javax.net.ssl.SSLContext sslcontext)
Assigns
SSLContext instance. |
HttpClientBuilder |
setSSLSocketFactory(LayeredConnectionSocketFactory sslSocketFactory)
Assigns
LayeredConnectionSocketFactory instance. |
HttpClientBuilder |
setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)
Assigns
AuthenticationStrategy instance for proxy
authentication. |
HttpClientBuilder |
setUserAgent(java.lang.String userAgent)
Assigns User-Agent value.
|
HttpClientBuilder |
setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
Assigns
UserTokenHandler instance. |
HttpClientBuilder |
useSystemProperties()
Use system properties when creating and configuring default
implementations.
|
public static HttpClientBuilder create()
public final HttpClientBuilder setRequestExecutor(org.apache.http.protocol.HttpRequestExecutor requestExec)
HttpRequestExecutor
instance.public final HttpClientBuilder setHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)
X509HostnameVerifier
instance.
Please note this value can be overridden by the setConnectionManager(
org.apache.http.conn.HttpClientConnectionManager)
and the setSSLSocketFactory(
org.apache.http.conn.socket.LayeredConnectionSocketFactory)
methods.public final HttpClientBuilder setSslcontext(javax.net.ssl.SSLContext sslcontext)
SSLContext
instance.
Please note this value can be overridden by the setConnectionManager(
org.apache.http.conn.HttpClientConnectionManager)
and the setSSLSocketFactory(
org.apache.http.conn.socket.LayeredConnectionSocketFactory)
methods.public final HttpClientBuilder setSSLSocketFactory(LayeredConnectionSocketFactory sslSocketFactory)
LayeredConnectionSocketFactory
instance.
Please note this value can be overridden by the setConnectionManager(
org.apache.http.conn.HttpClientConnectionManager)
method.public final HttpClientBuilder setMaxConnTotal(int maxConnTotal)
setConnectionManager(
org.apache.http.conn.HttpClientConnectionManager)
method.public final HttpClientBuilder setMaxConnPerRoute(int maxConnPerRoute)
setConnectionManager(
org.apache.http.conn.HttpClientConnectionManager)
method.public final HttpClientBuilder setDefaultSocketConfig(SocketConfig config)
SocketConfig
.
Please note this value can be overridden by the setConnectionManager(
org.apache.http.conn.HttpClientConnectionManager)
method.public final HttpClientBuilder setDefaultConnectionConfig(ConnectionConfig config)
ConnectionConfig
.
Please note this value can be overridden by the setConnectionManager(
org.apache.http.conn.HttpClientConnectionManager)
method.public final HttpClientBuilder setConnectionManager(HttpClientConnectionManager connManager)
HttpClientConnectionManager
instance.public final HttpClientBuilder setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
ConnectionReuseStrategy
instance.public final HttpClientBuilder setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
ConnectionKeepAliveStrategy
instance.public final HttpClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)
AuthenticationStrategy
instance for proxy
authentication.public final HttpClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)
AuthenticationStrategy
instance for target
host authentication.public final HttpClientBuilder setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
UserTokenHandler
instance.
Please note this value can be overridden by the disableConnectionState()
method.public final HttpClientBuilder disableConnectionState()
public final HttpClientBuilder setSchemePortResolver(SchemePortResolver schemePortResolver)
SchemePortResolver
instance.public final HttpClientBuilder setUserAgent(java.lang.String userAgent)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder setDefaultHeaders(java.util.Collection<? extends org.apache.http.Header> defaultHeaders)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder disableCookieManagement()
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder disableContentCompression()
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder disableAuthCaching()
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
HttpProcessor
instance.public final HttpClientBuilder setRetryHandler(org.apache.http.client.HttpRequestRetryHandler retryHandler)
HttpRequestRetryHandler
instance.
Please note this value can be overridden by the disableAutomaticRetries()
method.public final HttpClientBuilder disableAutomaticRetries()
public final HttpClientBuilder setProxy(org.apache.http.HttpHost proxy)
setRoutePlanner(
org.apache.http.conn.routing.HttpRoutePlanner)
method.public final HttpClientBuilder setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
HttpRoutePlanner
instance.public final HttpClientBuilder setRedirectStrategy(RedirectStrategy redirectStrategy)
RedirectStrategy
instance.
Please note this value can be overridden by the disableRedirectHandling()
method.
`public final HttpClientBuilder disableRedirectHandling()
public final HttpClientBuilder setConnectionBackoffStrategy(ConnectionBackoffStrategy connectionBackoffStrategy)
ConnectionBackoffStrategy
instance.public final HttpClientBuilder setBackoffManager(BackoffManager backoffManager)
BackoffManager
instance.public final HttpClientBuilder setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy serviceUnavailStrategy)
ServiceUnavailableRetryStrategy
instance.public final HttpClientBuilder setDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)
CookieStore
instance which will be used for
request execution if not explicitly set in the client execution context.public final HttpClientBuilder setDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
CredentialsProvider
instance which will be used
for request execution if not explicitly set in the client execution
context.public final HttpClientBuilder setDefaultAuthSchemeRegistry(Lookup<AuthSchemeProvider> authSchemeRegistry)
AuthScheme
registry which will
be used for request execution if not explicitly set in the client execution
context.public final HttpClientBuilder setDefaultCookieSpecRegistry(Lookup<CookieSpecProvider> cookieSpecRegistry)
CookieSpec
registry which will
be used for request execution if not explicitly set in the client execution
context.public final HttpClientBuilder setDefaultRequestConfig(RequestConfig config)
RequestConfig
instance which will be used
for request execution if not explicitly set in the client execution
context.public final HttpClientBuilder useSystemProperties()
protected ClientExecChain decorateMainExec(ClientExecChain mainExec)
protected ClientExecChain decorateProtocolExec(ClientExecChain protocolExec)
protected void addCloseable(java.io.Closeable closeable)
public CloseableHttpClient build()
Copyright © 1999-2015 The Apache Software Foundation. All rights reserved.