@NotThreadSafe public class HttpClientBuilder extends 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() |
public static HttpClientBuilder create()
public final HttpClientBuilder setRequestExecutor(HttpRequestExecutor requestExec)
HttpRequestExecutor
instance.public final HttpClientBuilder setHostnameVerifier(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(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(ConnectionReuseStrategy reuseStrategy)
ConnectionReuseStrategy
instance.public final HttpClientBuilder setKeepAliveStrategy(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(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(String userAgent)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder setDefaultHeaders(Collection<? extends Header> defaultHeaders)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder addInterceptorFirst(HttpResponseInterceptor itcp)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder addInterceptorLast(HttpResponseInterceptor itcp)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder addInterceptorFirst(HttpRequestInterceptor itcp)
setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.public final HttpClientBuilder addInterceptorLast(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(HttpProcessor httpprocessor)
HttpProcessor
instance.public final HttpClientBuilder setRetryHandler(HttpRequestRetryHandler retryHandler)
HttpRequestRetryHandler
instance.
Please note this value can be overridden by the disableAutomaticRetries()
method.public final HttpClientBuilder disableAutomaticRetries()
public final HttpClientBuilder setProxy(HttpHost proxy)
setRoutePlanner(
org.apache.http.conn.routing.HttpRoutePlanner)
method.public final HttpClientBuilder setRoutePlanner(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(CookieStore cookieStore)
CookieStore
instance which will be used for
request execution if not explicitly set in the client execution context.public final HttpClientBuilder setDefaultCredentialsProvider(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(Closeable closeable)
public CloseableHttpClient build()
Copyright © 1999–2014 The Apache Software Foundation. All rights reserved.