Class HttpClientBuilder
- java.lang.Object
-
- org.apache.http.impl.client.HttpClientBuilder
-
public class HttpClientBuilder extends java.lang.Object
Builder forCloseableHttpClient
instances.When a particular component is not explicitly set 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 callingbuild()
.- ssl.TrustManagerFactory.algorithm
- javax.net.ssl.trustStoreType
- javax.net.ssl.trustStore
- javax.net.ssl.trustStoreProvider
- javax.net.ssl.trustStorePassword
- ssl.KeyManagerFactory.algorithm
- javax.net.ssl.keyStoreType
- javax.net.ssl.keyStore
- javax.net.ssl.keyStoreProvider
- javax.net.ssl.keyStorePassword
- https.protocols
- https.cipherSuites
- http.proxyHost
- http.proxyPort
- https.proxyHost
- https.proxyPort
- http.nonProxyHosts
- http.keepAlive
- http.maxConnections
- http.agent
Please note that some settings used by this class can be mutually exclusive and may not apply when building
CloseableHttpClient
instances.- Since:
- 4.3
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
authCachingDisabled
private org.apache.http.config.Lookup<AuthSchemeProvider>
authSchemeRegistry
private boolean
automaticRetriesDisabled
private BackoffManager
backoffManager
private java.util.List<java.io.Closeable>
closeables
private ConnectionBackoffStrategy
connectionBackoffStrategy
private boolean
connectionStateDisabled
private HttpClientConnectionManager
connManager
private boolean
connManagerShared
private long
connTimeToLive
private java.util.concurrent.TimeUnit
connTimeToLiveTimeUnit
private boolean
contentCompressionDisabled
private java.util.Map<java.lang.String,InputStreamFactory>
contentDecoderMap
private boolean
cookieManagementDisabled
private org.apache.http.config.Lookup<CookieSpecProvider>
cookieSpecRegistry
private CookieStore
cookieStore
private CredentialsProvider
credentialsProvider
private org.apache.http.config.ConnectionConfig
defaultConnectionConfig
private java.util.Collection<? extends org.apache.http.Header>
defaultHeaders
private RequestConfig
defaultRequestConfig
private org.apache.http.config.SocketConfig
defaultSocketConfig
private boolean
defaultUserAgentDisabled
private DnsResolver
dnsResolver
private boolean
evictExpiredConnections
private boolean
evictIdleConnections
private javax.net.ssl.HostnameVerifier
hostnameVerifier
private org.apache.http.protocol.HttpProcessor
httpprocessor
private ConnectionKeepAliveStrategy
keepAliveStrategy
private int
maxConnPerRoute
private int
maxConnTotal
private long
maxIdleTime
private java.util.concurrent.TimeUnit
maxIdleTimeUnit
private org.apache.http.HttpHost
proxy
private AuthenticationStrategy
proxyAuthStrategy
private PublicSuffixMatcher
publicSuffixMatcher
private boolean
redirectHandlingDisabled
private RedirectStrategy
redirectStrategy
private org.apache.http.protocol.HttpRequestExecutor
requestExec
private java.util.LinkedList<org.apache.http.HttpRequestInterceptor>
requestFirst
private java.util.LinkedList<org.apache.http.HttpRequestInterceptor>
requestLast
private java.util.LinkedList<org.apache.http.HttpResponseInterceptor>
responseFirst
private java.util.LinkedList<org.apache.http.HttpResponseInterceptor>
responseLast
private HttpRequestRetryHandler
retryHandler
private org.apache.http.ConnectionReuseStrategy
reuseStrategy
private HttpRoutePlanner
routePlanner
private SchemePortResolver
schemePortResolver
private ServiceUnavailableRetryStrategy
serviceUnavailStrategy
private javax.net.ssl.SSLContext
sslContext
private LayeredConnectionSocketFactory
sslSocketFactory
private boolean
systemProperties
private AuthenticationStrategy
targetAuthStrategy
private java.lang.String
userAgent
private UserTokenHandler
userTokenHandler
-
Constructor Summary
Constructors Modifier Constructor Description protected
HttpClientBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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
createMainExec(org.apache.http.protocol.HttpRequestExecutor requestExec, HttpClientConnectionManager connManager, org.apache.http.ConnectionReuseStrategy reuseStrategy, ConnectionKeepAliveStrategy keepAliveStrategy, org.apache.http.protocol.HttpProcessor proxyHttpProcessor, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler)
Produces an instance ofClientExecChain
to be used as a main exec.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
disableDefaultUserAgent()
Disables the default user agent set by this builder if none has been provided by the user.HttpClientBuilder
disableRedirectHandling()
Disables automatic redirect handling.HttpClientBuilder
evictExpiredConnections()
Makes this instance of HttpClient proactively evict expired connections from the connection pool using a background thread.HttpClientBuilder
evictIdleConnections(long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
Makes this instance of HttpClient proactively evict idle connections from the connection pool using a background thread.HttpClientBuilder
evictIdleConnections(java.lang.Long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
Deprecated.(4.5) useevictIdleConnections(long, TimeUnit)
HttpClientBuilder
setBackoffManager(BackoffManager backoffManager)
AssignsBackoffManager
instance.HttpClientBuilder
setConnectionBackoffStrategy(ConnectionBackoffStrategy connectionBackoffStrategy)
AssignsConnectionBackoffStrategy
instance.HttpClientBuilder
setConnectionManager(HttpClientConnectionManager connManager)
AssignsHttpClientConnectionManager
instance.HttpClientBuilder
setConnectionManagerShared(boolean shared)
Defines the connection manager is to be shared by multiple client instances.HttpClientBuilder
setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
AssignsConnectionReuseStrategy
instance.HttpClientBuilder
setConnectionTimeToLive(long connTimeToLive, java.util.concurrent.TimeUnit connTimeToLiveTimeUnit)
Sets maximum time to live for persistent connectionsHttpClientBuilder
setContentDecoderRegistry(java.util.Map<java.lang.String,InputStreamFactory> contentDecoderMap)
Assigns a map ofInputStreamFactory
s to be used for automatic content decompression.HttpClientBuilder
setDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<AuthSchemeProvider> authSchemeRegistry)
Assigns defaultAuthScheme
registry which will be used for request execution if not explicitly set in the client execution context.HttpClientBuilder
setDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)
Assigns defaultConnectionConfig
.HttpClientBuilder
setDefaultCookieSpecRegistry(org.apache.http.config.Lookup<CookieSpecProvider> cookieSpecRegistry)
Assigns defaultCookieSpec
registry which will be used for request execution if not explicitly set in the client execution context.HttpClientBuilder
setDefaultCookieStore(CookieStore cookieStore)
Assigns defaultCookieStore
instance which will be used for request execution if not explicitly set in the client execution context.HttpClientBuilder
setDefaultCredentialsProvider(CredentialsProvider credentialsProvider)
Assigns defaultCredentialsProvider
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 defaultRequestConfig
instance which will be used for request execution if not explicitly set in the client execution context.HttpClientBuilder
setDefaultSocketConfig(org.apache.http.config.SocketConfig config)
Assigns defaultSocketConfig
.HttpClientBuilder
setDnsResolver(DnsResolver dnsResolver)
AssignsDnsResolver
instance.HttpClientBuilder
setHostnameVerifier(X509HostnameVerifier hostnameVerifier)
Deprecated.(4.4)HttpClientBuilder
setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
AssignsHttpProcessor
instance.HttpClientBuilder
setKeepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy)
AssignsConnectionKeepAliveStrategy
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)
AssignsAuthenticationStrategy
instance for proxy authentication.HttpClientBuilder
setPublicSuffixMatcher(PublicSuffixMatcher publicSuffixMatcher)
Assigns file containing public suffix matcher.HttpClientBuilder
setRedirectStrategy(RedirectStrategy redirectStrategy)
AssignsRedirectStrategy
instance.HttpClientBuilder
setRequestExecutor(org.apache.http.protocol.HttpRequestExecutor requestExec)
AssignsHttpRequestExecutor
instance.HttpClientBuilder
setRetryHandler(HttpRequestRetryHandler retryHandler)
AssignsHttpRequestRetryHandler
instance.HttpClientBuilder
setRoutePlanner(HttpRoutePlanner routePlanner)
AssignsHttpRoutePlanner
instance.HttpClientBuilder
setSchemePortResolver(SchemePortResolver schemePortResolver)
AssignsSchemePortResolver
instance.HttpClientBuilder
setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy serviceUnavailStrategy)
AssignsServiceUnavailableRetryStrategy
instance.HttpClientBuilder
setSslcontext(javax.net.ssl.SSLContext sslcontext)
Deprecated.(4.5) usesetSSLContext(SSLContext)
HttpClientBuilder
setSSLContext(javax.net.ssl.SSLContext sslContext)
AssignsSSLContext
instance.HttpClientBuilder
setSSLHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
AssignsHostnameVerifier
instance.HttpClientBuilder
setSSLSocketFactory(LayeredConnectionSocketFactory sslSocketFactory)
AssignsLayeredConnectionSocketFactory
instance.HttpClientBuilder
setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)
AssignsAuthenticationStrategy
instance for target host authentication.HttpClientBuilder
setUserAgent(java.lang.String userAgent)
AssignsUser-Agent
value.HttpClientBuilder
setUserTokenHandler(UserTokenHandler userTokenHandler)
AssignsUserTokenHandler
instance.private static java.lang.String[]
split(java.lang.String s)
HttpClientBuilder
useSystemProperties()
Use system properties when creating and configuring default implementations.
-
-
-
Field Detail
-
requestExec
private org.apache.http.protocol.HttpRequestExecutor requestExec
-
hostnameVerifier
private javax.net.ssl.HostnameVerifier hostnameVerifier
-
sslSocketFactory
private LayeredConnectionSocketFactory sslSocketFactory
-
sslContext
private javax.net.ssl.SSLContext sslContext
-
connManager
private HttpClientConnectionManager connManager
-
connManagerShared
private boolean connManagerShared
-
schemePortResolver
private SchemePortResolver schemePortResolver
-
reuseStrategy
private org.apache.http.ConnectionReuseStrategy reuseStrategy
-
keepAliveStrategy
private ConnectionKeepAliveStrategy keepAliveStrategy
-
targetAuthStrategy
private AuthenticationStrategy targetAuthStrategy
-
proxyAuthStrategy
private AuthenticationStrategy proxyAuthStrategy
-
userTokenHandler
private UserTokenHandler userTokenHandler
-
httpprocessor
private org.apache.http.protocol.HttpProcessor httpprocessor
-
dnsResolver
private DnsResolver dnsResolver
-
requestFirst
private java.util.LinkedList<org.apache.http.HttpRequestInterceptor> requestFirst
-
requestLast
private java.util.LinkedList<org.apache.http.HttpRequestInterceptor> requestLast
-
responseFirst
private java.util.LinkedList<org.apache.http.HttpResponseInterceptor> responseFirst
-
responseLast
private java.util.LinkedList<org.apache.http.HttpResponseInterceptor> responseLast
-
retryHandler
private HttpRequestRetryHandler retryHandler
-
routePlanner
private HttpRoutePlanner routePlanner
-
redirectStrategy
private RedirectStrategy redirectStrategy
-
connectionBackoffStrategy
private ConnectionBackoffStrategy connectionBackoffStrategy
-
backoffManager
private BackoffManager backoffManager
-
serviceUnavailStrategy
private ServiceUnavailableRetryStrategy serviceUnavailStrategy
-
authSchemeRegistry
private org.apache.http.config.Lookup<AuthSchemeProvider> authSchemeRegistry
-
cookieSpecRegistry
private org.apache.http.config.Lookup<CookieSpecProvider> cookieSpecRegistry
-
contentDecoderMap
private java.util.Map<java.lang.String,InputStreamFactory> contentDecoderMap
-
cookieStore
private CookieStore cookieStore
-
credentialsProvider
private CredentialsProvider credentialsProvider
-
userAgent
private java.lang.String userAgent
-
proxy
private org.apache.http.HttpHost proxy
-
defaultHeaders
private java.util.Collection<? extends org.apache.http.Header> defaultHeaders
-
defaultSocketConfig
private org.apache.http.config.SocketConfig defaultSocketConfig
-
defaultConnectionConfig
private org.apache.http.config.ConnectionConfig defaultConnectionConfig
-
defaultRequestConfig
private RequestConfig defaultRequestConfig
-
evictExpiredConnections
private boolean evictExpiredConnections
-
evictIdleConnections
private boolean evictIdleConnections
-
maxIdleTime
private long maxIdleTime
-
maxIdleTimeUnit
private java.util.concurrent.TimeUnit maxIdleTimeUnit
-
systemProperties
private boolean systemProperties
-
redirectHandlingDisabled
private boolean redirectHandlingDisabled
-
automaticRetriesDisabled
private boolean automaticRetriesDisabled
-
contentCompressionDisabled
private boolean contentCompressionDisabled
-
cookieManagementDisabled
private boolean cookieManagementDisabled
-
authCachingDisabled
private boolean authCachingDisabled
-
connectionStateDisabled
private boolean connectionStateDisabled
-
defaultUserAgentDisabled
private boolean defaultUserAgentDisabled
-
maxConnTotal
private int maxConnTotal
-
maxConnPerRoute
private int maxConnPerRoute
-
connTimeToLive
private long connTimeToLive
-
connTimeToLiveTimeUnit
private java.util.concurrent.TimeUnit connTimeToLiveTimeUnit
-
closeables
private java.util.List<java.io.Closeable> closeables
-
publicSuffixMatcher
private PublicSuffixMatcher publicSuffixMatcher
-
-
Method Detail
-
create
public static HttpClientBuilder create()
-
setRequestExecutor
public final HttpClientBuilder setRequestExecutor(org.apache.http.protocol.HttpRequestExecutor requestExec)
AssignsHttpRequestExecutor
instance.
-
setHostnameVerifier
@Deprecated public final HttpClientBuilder setHostnameVerifier(X509HostnameVerifier hostnameVerifier)
Deprecated.(4.4)AssignsX509HostnameVerifier
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
and thesetSSLSocketFactory( org.apache.http.conn.socket.LayeredConnectionSocketFactory)
methods.
-
setSSLHostnameVerifier
public final HttpClientBuilder setSSLHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
AssignsHostnameVerifier
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
and thesetSSLSocketFactory( org.apache.http.conn.socket.LayeredConnectionSocketFactory)
methods.- Since:
- 4.4
-
setPublicSuffixMatcher
public final HttpClientBuilder setPublicSuffixMatcher(PublicSuffixMatcher publicSuffixMatcher)
Assigns file containing public suffix matcher. Instances of this class can be created withPublicSuffixMatcherLoader
.- Since:
- 4.4
- See Also:
PublicSuffixMatcher
,PublicSuffixMatcherLoader
-
setSslcontext
@Deprecated public final HttpClientBuilder setSslcontext(javax.net.ssl.SSLContext sslcontext)
Deprecated.(4.5) usesetSSLContext(SSLContext)
AssignsSSLContext
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
and thesetSSLSocketFactory( org.apache.http.conn.socket.LayeredConnectionSocketFactory)
methods.
-
setSSLContext
public final HttpClientBuilder setSSLContext(javax.net.ssl.SSLContext sslContext)
AssignsSSLContext
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
and thesetSSLSocketFactory( org.apache.http.conn.socket.LayeredConnectionSocketFactory)
methods.
-
setSSLSocketFactory
public final HttpClientBuilder setSSLSocketFactory(LayeredConnectionSocketFactory sslSocketFactory)
AssignsLayeredConnectionSocketFactory
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
method.
-
setMaxConnTotal
public final HttpClientBuilder setMaxConnTotal(int maxConnTotal)
Assigns maximum total connection value.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
method.
-
setMaxConnPerRoute
public final HttpClientBuilder setMaxConnPerRoute(int maxConnPerRoute)
Assigns maximum connection per route value.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
method.
-
setDefaultSocketConfig
public final HttpClientBuilder setDefaultSocketConfig(org.apache.http.config.SocketConfig config)
Assigns defaultSocketConfig
.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
method.
-
setDefaultConnectionConfig
public final HttpClientBuilder setDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)
Assigns defaultConnectionConfig
.Please note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
method.
-
setConnectionTimeToLive
public final HttpClientBuilder setConnectionTimeToLive(long connTimeToLive, java.util.concurrent.TimeUnit connTimeToLiveTimeUnit)
Sets maximum time to live for persistent connectionsPlease note this value can be overridden by the
setConnectionManager( org.apache.http.conn.HttpClientConnectionManager)
method.- Since:
- 4.4
-
setConnectionManager
public final HttpClientBuilder setConnectionManager(HttpClientConnectionManager connManager)
AssignsHttpClientConnectionManager
instance.
-
setConnectionManagerShared
public final HttpClientBuilder setConnectionManagerShared(boolean shared)
Defines the connection manager is to be shared by multiple client instances.If the connection manager is shared its life-cycle is expected to be managed by the caller and it will not be shut down if the client is closed.
- Parameters:
shared
- defines whether or not the connection manager can be shared by multiple clients.- Since:
- 4.4
-
setConnectionReuseStrategy
public final HttpClientBuilder setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
AssignsConnectionReuseStrategy
instance.
-
setKeepAliveStrategy
public final HttpClientBuilder setKeepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy)
AssignsConnectionKeepAliveStrategy
instance.
-
setTargetAuthenticationStrategy
public final HttpClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)
AssignsAuthenticationStrategy
instance for target host authentication.
-
setProxyAuthenticationStrategy
public final HttpClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)
AssignsAuthenticationStrategy
instance for proxy authentication.
-
setUserTokenHandler
public final HttpClientBuilder setUserTokenHandler(UserTokenHandler userTokenHandler)
AssignsUserTokenHandler
instance.Please note this value can be overridden by the
disableConnectionState()
method.
-
disableConnectionState
public final HttpClientBuilder disableConnectionState()
Disables connection state tracking.
-
setSchemePortResolver
public final HttpClientBuilder setSchemePortResolver(SchemePortResolver schemePortResolver)
AssignsSchemePortResolver
instance.
-
setUserAgent
public final HttpClientBuilder setUserAgent(java.lang.String userAgent)
AssignsUser-Agent
value.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
setDefaultHeaders
public final HttpClientBuilder setDefaultHeaders(java.util.Collection<? extends org.apache.http.Header> defaultHeaders)
Assigns default request header values.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
addInterceptorFirst
public final HttpClientBuilder addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
addInterceptorLast
public final HttpClientBuilder addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
addInterceptorFirst
public final HttpClientBuilder addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
addInterceptorLast
public final HttpClientBuilder addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
disableCookieManagement
public final HttpClientBuilder disableCookieManagement()
Disables state (cookie) management.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
disableContentCompression
public final HttpClientBuilder disableContentCompression()
Disables automatic content decompression.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
disableAuthCaching
public final HttpClientBuilder disableAuthCaching()
Disables authentication scheme caching.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
setHttpProcessor
public final HttpClientBuilder setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
AssignsHttpProcessor
instance.
-
setDnsResolver
public final HttpClientBuilder setDnsResolver(DnsResolver dnsResolver)
AssignsDnsResolver
instance.Please note this value can be overridden by the
setConnectionManager(HttpClientConnectionManager)
method.
-
setRetryHandler
public final HttpClientBuilder setRetryHandler(HttpRequestRetryHandler retryHandler)
AssignsHttpRequestRetryHandler
instance.Please note this value can be overridden by the
disableAutomaticRetries()
method.
-
disableAutomaticRetries
public final HttpClientBuilder disableAutomaticRetries()
Disables automatic request recovery and re-execution.
-
setProxy
public final HttpClientBuilder setProxy(org.apache.http.HttpHost proxy)
Assigns default proxy value.Please note this value can be overridden by the
setRoutePlanner( org.apache.http.conn.routing.HttpRoutePlanner)
method.
-
setRoutePlanner
public final HttpClientBuilder setRoutePlanner(HttpRoutePlanner routePlanner)
AssignsHttpRoutePlanner
instance.
-
setRedirectStrategy
public final HttpClientBuilder setRedirectStrategy(RedirectStrategy redirectStrategy)
AssignsRedirectStrategy
instance.Please note this value can be overridden by the
`disableRedirectHandling()
method.
-
disableRedirectHandling
public final HttpClientBuilder disableRedirectHandling()
Disables automatic redirect handling.
-
setConnectionBackoffStrategy
public final HttpClientBuilder setConnectionBackoffStrategy(ConnectionBackoffStrategy connectionBackoffStrategy)
AssignsConnectionBackoffStrategy
instance.
-
setBackoffManager
public final HttpClientBuilder setBackoffManager(BackoffManager backoffManager)
AssignsBackoffManager
instance.
-
setServiceUnavailableRetryStrategy
public final HttpClientBuilder setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy serviceUnavailStrategy)
AssignsServiceUnavailableRetryStrategy
instance.
-
setDefaultCookieStore
public final HttpClientBuilder setDefaultCookieStore(CookieStore cookieStore)
Assigns defaultCookieStore
instance which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultCredentialsProvider
public final HttpClientBuilder setDefaultCredentialsProvider(CredentialsProvider credentialsProvider)
Assigns defaultCredentialsProvider
instance which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultAuthSchemeRegistry
public final HttpClientBuilder setDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<AuthSchemeProvider> authSchemeRegistry)
Assigns defaultAuthScheme
registry which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultCookieSpecRegistry
public final HttpClientBuilder setDefaultCookieSpecRegistry(org.apache.http.config.Lookup<CookieSpecProvider> cookieSpecRegistry)
Assigns defaultCookieSpec
registry which will be used for request execution if not explicitly set in the client execution context.- See Also:
CookieSpecRegistries
-
setContentDecoderRegistry
public final HttpClientBuilder setContentDecoderRegistry(java.util.Map<java.lang.String,InputStreamFactory> contentDecoderMap)
Assigns a map ofInputStreamFactory
s to be used for automatic content decompression.
-
setDefaultRequestConfig
public final HttpClientBuilder setDefaultRequestConfig(RequestConfig config)
Assigns defaultRequestConfig
instance which will be used for request execution if not explicitly set in the client execution context.
-
useSystemProperties
public final HttpClientBuilder useSystemProperties()
Use system properties when creating and configuring default implementations.
-
evictExpiredConnections
public final HttpClientBuilder evictExpiredConnections()
Makes this instance of HttpClient proactively evict expired connections from the connection pool using a background thread.One MUST explicitly close HttpClient with
Closeable.close()
in order to stop and release the background thread.Please note this method has no effect if the instance of HttpClient is configuted to use a shared connection manager.
Please note this method may not be used when the instance of HttpClient is created inside an EJB container.
- Since:
- 4.4
- See Also:
setConnectionManagerShared(boolean)
,HttpClientConnectionManager.closeExpiredConnections()
-
evictIdleConnections
@Deprecated public final HttpClientBuilder evictIdleConnections(java.lang.Long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
Deprecated.(4.5) useevictIdleConnections(long, TimeUnit)
Makes this instance of HttpClient proactively evict idle connections from the connection pool using a background thread.One MUST explicitly close HttpClient with
Closeable.close()
in order to stop and release the background thread.Please note this method has no effect if the instance of HttpClient is configuted to use a shared connection manager.
Please note this method may not be used when the instance of HttpClient is created inside an EJB container.
- Parameters:
maxIdleTime
- maximum time persistent connections can stay idle while kept alive in the connection pool. Connections whose inactivity period exceeds this value will get closed and evicted from the pool.maxIdleTimeUnit
- time unit for the above parameter.- Since:
- 4.4
- See Also:
setConnectionManagerShared(boolean)
,HttpClientConnectionManager.closeExpiredConnections()
-
evictIdleConnections
public final HttpClientBuilder evictIdleConnections(long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
Makes this instance of HttpClient proactively evict idle connections from the connection pool using a background thread.One MUST explicitly close HttpClient with
Closeable.close()
in order to stop and release the background thread.Please note this method has no effect if the instance of HttpClient is configuted to use a shared connection manager.
Please note this method may not be used when the instance of HttpClient is created inside an EJB container.
- Parameters:
maxIdleTime
- maximum time persistent connections can stay idle while kept alive in the connection pool. Connections whose inactivity period exceeds this value will get closed and evicted from the pool.maxIdleTimeUnit
- time unit for the above parameter.- Since:
- 4.4
- See Also:
setConnectionManagerShared(boolean)
,HttpClientConnectionManager.closeExpiredConnections()
-
disableDefaultUserAgent
public final HttpClientBuilder disableDefaultUserAgent()
Disables the default user agent set by this builder if none has been provided by the user.- Since:
- 4.5.7
-
createMainExec
protected ClientExecChain createMainExec(org.apache.http.protocol.HttpRequestExecutor requestExec, HttpClientConnectionManager connManager, org.apache.http.ConnectionReuseStrategy reuseStrategy, ConnectionKeepAliveStrategy keepAliveStrategy, org.apache.http.protocol.HttpProcessor proxyHttpProcessor, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler)
Produces an instance ofClientExecChain
to be used as a main exec.Default implementation produces an instance of
MainClientExec
For internal use.
- Since:
- 4.4
-
decorateMainExec
protected ClientExecChain decorateMainExec(ClientExecChain mainExec)
For internal use.
-
decorateProtocolExec
protected ClientExecChain decorateProtocolExec(ClientExecChain protocolExec)
For internal use.
-
addCloseable
protected void addCloseable(java.io.Closeable closeable)
For internal use.
-
split
private static java.lang.String[] split(java.lang.String s)
-
build
public CloseableHttpClient build()
-
-