Class HttpAsyncClientBuilder
- java.lang.Object
-
- org.apache.http.impl.nio.client.HttpAsyncClientBuilder
-
public class HttpAsyncClientBuilder extends java.lang.Object
Builder forCloseableHttpAsyncClient
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 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
- 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
CloseableHttpAsyncClient
instances.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
authCachingDisabled
private org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider>
authSchemeRegistry
private boolean
connectionStateDisabled
private NHttpClientConnectionManager
connManager
private boolean
connManagerShared
private boolean
cookieManagementDisabled
private org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider>
cookieSpecRegistry
private org.apache.http.client.CookieStore
cookieStore
private org.apache.http.client.CredentialsProvider
credentialsProvider
private org.apache.http.config.ConnectionConfig
defaultConnectionConfig
private java.util.Collection<? extends org.apache.http.Header>
defaultHeaders
private org.apache.http.impl.nio.reactor.IOReactorConfig
defaultIOReactorConfig
private org.apache.http.client.config.RequestConfig
defaultRequestConfig
private org.apache.http.nio.NHttpClientEventHandler
eventHandler
private javax.net.ssl.HostnameVerifier
hostnameVerifier
private org.apache.http.protocol.HttpProcessor
httpprocessor
private org.apache.http.conn.ConnectionKeepAliveStrategy
keepAliveStrategy
private int
maxConnPerRoute
private int
maxConnTotal
private org.apache.http.HttpHost
proxy
private org.apache.http.client.AuthenticationStrategy
proxyAuthStrategy
private org.apache.http.conn.util.PublicSuffixMatcher
publicSuffixMatcher
private org.apache.http.client.RedirectStrategy
redirectStrategy
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 org.apache.http.ConnectionReuseStrategy
reuseStrategy
private org.apache.http.conn.routing.HttpRoutePlanner
routePlanner
private org.apache.http.conn.SchemePortResolver
schemePortResolver
private javax.net.ssl.SSLContext
sslcontext
private SchemeIOSessionStrategy
sslStrategy
private boolean
systemProperties
private org.apache.http.client.AuthenticationStrategy
targetAuthStrategy
private java.util.concurrent.ThreadFactory
threadFactory
private java.lang.String
userAgent
private org.apache.http.client.UserTokenHandler
userTokenHandler
-
Constructor Summary
Constructors Modifier Constructor Description protected
HttpAsyncClientBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HttpAsyncClientBuilder
addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.HttpAsyncClientBuilder
addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.HttpAsyncClientBuilder
addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.HttpAsyncClientBuilder
addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.CloseableHttpAsyncClient
build()
static HttpAsyncClientBuilder
create()
HttpAsyncClientBuilder
disableAuthCaching()
Disables authentication scheme caching.HttpAsyncClientBuilder
disableConnectionState()
Disables connection state tracking.HttpAsyncClientBuilder
disableCookieManagement()
Disables state (cookie) management.HttpAsyncClientBuilder
setConnectionManager(NHttpClientConnectionManager connManager)
AssignsNHttpClientConnectionManager
instance.HttpAsyncClientBuilder
setConnectionManagerShared(boolean shared)
Defines the connection manager is to be shared by multiple client instances.HttpAsyncClientBuilder
setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
AssignsConnectionReuseStrategy
instance.HttpAsyncClientBuilder
setDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry)
Assigns defaultAuthScheme
registry which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuilder
setDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)
Assigns defaultConnectionConfig
.HttpAsyncClientBuilder
setDefaultCookieSpecRegistry(org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry)
Assigns defaultCookieSpec
registry which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuilder
setDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)
Assigns defaultCookieStore
instance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuilder
setDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
Assigns defaultCredentialsProvider
instance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuilder
setDefaultHeaders(java.util.Collection<? extends org.apache.http.Header> defaultHeaders)
Assigns default request header values.HttpAsyncClientBuilder
setDefaultIOReactorConfig(org.apache.http.impl.nio.reactor.IOReactorConfig config)
Assigns defaultIOReactorConfig
.HttpAsyncClientBuilder
setDefaultRequestConfig(org.apache.http.client.config.RequestConfig config)
Assigns defaultRequestConfig
instance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuilder
setEventHandler(org.apache.http.nio.NHttpClientEventHandler eventHandler)
AssignsNHttpClientEventHandler
instance.HttpAsyncClientBuilder
setHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)
Deprecated.HttpAsyncClientBuilder
setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
AssignsHttpProcessor
instance.HttpAsyncClientBuilder
setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
AssignsConnectionKeepAliveStrategy
instance.HttpAsyncClientBuilder
setMaxConnPerRoute(int maxConnPerRoute)
Assigns maximum connection per route value.HttpAsyncClientBuilder
setMaxConnTotal(int maxConnTotal)
Assigns maximum total connection value.HttpAsyncClientBuilder
setProxy(org.apache.http.HttpHost proxy)
Assigns default proxy value.HttpAsyncClientBuilder
setProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy proxyAuthStrategy)
AssignsAuthenticationStrategy
instance for target host authentication.HttpAsyncClientBuilder
setPublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher)
Assigns file containing public suffix matcher.HttpAsyncClientBuilder
setRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)
AssignsRedirectStrategy
instance.HttpAsyncClientBuilder
setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
AssignsHttpRoutePlanner
instance.HttpAsyncClientBuilder
setSchemePortResolver(org.apache.http.conn.SchemePortResolver schemePortResolver)
AssignsSchemePortResolver
instance.HttpAsyncClientBuilder
setSSLContext(javax.net.ssl.SSLContext sslcontext)
AssignsSSLContext
instance.HttpAsyncClientBuilder
setSSLHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
AssignsHostnameVerifier
instance.HttpAsyncClientBuilder
setSSLStrategy(SchemeIOSessionStrategy strategy)
AssignsSchemeIOSessionStrategy
instance.HttpAsyncClientBuilder
setTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy targetAuthStrategy)
AssignsAuthenticationStrategy
instance for proxy authentication.HttpAsyncClientBuilder
setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
AssignsThreadFactory
instance.HttpAsyncClientBuilder
setUserAgent(java.lang.String userAgent)
AssignsUser-Agent
value.HttpAsyncClientBuilder
setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
AssignsUserTokenHandler
instance.private static java.lang.String[]
split(java.lang.String s)
HttpAsyncClientBuilder
useSystemProperties()
Use system properties when creating and configuring default implementations.
-
-
-
Field Detail
-
connManager
private NHttpClientConnectionManager connManager
-
connManagerShared
private boolean connManagerShared
-
schemePortResolver
private org.apache.http.conn.SchemePortResolver schemePortResolver
-
sslStrategy
private SchemeIOSessionStrategy sslStrategy
-
hostnameVerifier
private javax.net.ssl.HostnameVerifier hostnameVerifier
-
sslcontext
private javax.net.ssl.SSLContext sslcontext
-
reuseStrategy
private org.apache.http.ConnectionReuseStrategy reuseStrategy
-
keepAliveStrategy
private org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy
-
targetAuthStrategy
private org.apache.http.client.AuthenticationStrategy targetAuthStrategy
-
proxyAuthStrategy
private org.apache.http.client.AuthenticationStrategy proxyAuthStrategy
-
userTokenHandler
private org.apache.http.client.UserTokenHandler userTokenHandler
-
httpprocessor
private org.apache.http.protocol.HttpProcessor httpprocessor
-
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
-
routePlanner
private org.apache.http.conn.routing.HttpRoutePlanner routePlanner
-
redirectStrategy
private org.apache.http.client.RedirectStrategy redirectStrategy
-
authSchemeRegistry
private org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry
-
cookieSpecRegistry
private org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry
-
cookieStore
private org.apache.http.client.CookieStore cookieStore
-
credentialsProvider
private org.apache.http.client.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
-
defaultIOReactorConfig
private org.apache.http.impl.nio.reactor.IOReactorConfig defaultIOReactorConfig
-
defaultConnectionConfig
private org.apache.http.config.ConnectionConfig defaultConnectionConfig
-
defaultRequestConfig
private org.apache.http.client.config.RequestConfig defaultRequestConfig
-
threadFactory
private java.util.concurrent.ThreadFactory threadFactory
-
eventHandler
private org.apache.http.nio.NHttpClientEventHandler eventHandler
-
publicSuffixMatcher
private org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher
-
systemProperties
private boolean systemProperties
-
cookieManagementDisabled
private boolean cookieManagementDisabled
-
authCachingDisabled
private boolean authCachingDisabled
-
connectionStateDisabled
private boolean connectionStateDisabled
-
maxConnTotal
private int maxConnTotal
-
maxConnPerRoute
private int maxConnPerRoute
-
-
Method Detail
-
create
public static HttpAsyncClientBuilder create()
-
setPublicSuffixMatcher
public final HttpAsyncClientBuilder setPublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher)
Assigns file containing public suffix matcher. Instances of this class can be created withPublicSuffixMatcherLoader
.- Since:
- 4.1
- See Also:
PublicSuffixMatcher
,PublicSuffixMatcherLoader
-
setConnectionManager
public final HttpAsyncClientBuilder setConnectionManager(NHttpClientConnectionManager connManager)
AssignsNHttpClientConnectionManager
instance.
-
setConnectionManagerShared
public final HttpAsyncClientBuilder 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.1
-
setSchemePortResolver
public final HttpAsyncClientBuilder setSchemePortResolver(org.apache.http.conn.SchemePortResolver schemePortResolver)
AssignsSchemePortResolver
instance.
-
setMaxConnTotal
public final HttpAsyncClientBuilder setMaxConnTotal(int maxConnTotal)
Assigns maximum total connection value.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)
method.
-
setMaxConnPerRoute
public final HttpAsyncClientBuilder setMaxConnPerRoute(int maxConnPerRoute)
Assigns maximum connection per route value.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)
method.
-
setConnectionReuseStrategy
public final HttpAsyncClientBuilder setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
AssignsConnectionReuseStrategy
instance.
-
setKeepAliveStrategy
public final HttpAsyncClientBuilder setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
AssignsConnectionKeepAliveStrategy
instance.
-
setUserTokenHandler
public final HttpAsyncClientBuilder setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
AssignsUserTokenHandler
instance.Please note this value can be overridden by the
disableConnectionState()
method.
-
setTargetAuthenticationStrategy
public final HttpAsyncClientBuilder setTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy targetAuthStrategy)
AssignsAuthenticationStrategy
instance for proxy authentication.
-
setProxyAuthenticationStrategy
public final HttpAsyncClientBuilder setProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy proxyAuthStrategy)
AssignsAuthenticationStrategy
instance for target host authentication.
-
setHttpProcessor
public final HttpAsyncClientBuilder setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
AssignsHttpProcessor
instance.
-
addInterceptorFirst
public final HttpAsyncClientBuilder 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 HttpAsyncClientBuilder 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 HttpAsyncClientBuilder 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 HttpAsyncClientBuilder 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.
-
setRoutePlanner
public final HttpAsyncClientBuilder setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
AssignsHttpRoutePlanner
instance.
-
setRedirectStrategy
public final HttpAsyncClientBuilder setRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)
AssignsRedirectStrategy
instance.
-
setDefaultCookieStore
public final HttpAsyncClientBuilder setDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)
Assigns defaultCookieStore
instance which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultCredentialsProvider
public final HttpAsyncClientBuilder setDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
Assigns defaultCredentialsProvider
instance which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultAuthSchemeRegistry
public final HttpAsyncClientBuilder setDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry)
Assigns defaultAuthScheme
registry which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultCookieSpecRegistry
public final HttpAsyncClientBuilder setDefaultCookieSpecRegistry(org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry)
Assigns defaultCookieSpec
registry which will be used for request execution if not explicitly set in the client execution context.
-
setUserAgent
public final HttpAsyncClientBuilder setUserAgent(java.lang.String userAgent)
AssignsUser-Agent
value.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
setProxy
public final HttpAsyncClientBuilder 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.
-
setSSLStrategy
public final HttpAsyncClientBuilder setSSLStrategy(SchemeIOSessionStrategy strategy)
AssignsSchemeIOSessionStrategy
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)
method.
-
setSSLContext
public final HttpAsyncClientBuilder setSSLContext(javax.net.ssl.SSLContext sslcontext)
AssignsSSLContext
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)
and thesetSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy)
methods.
-
setHostnameVerifier
@Deprecated public final HttpAsyncClientBuilder setHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)
Deprecated.AssignsX509HostnameVerifier
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)
and thesetSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy)
methods.
-
setSSLHostnameVerifier
public final HttpAsyncClientBuilder setSSLHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
AssignsHostnameVerifier
instance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)
and thesetSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy)
methods.- Since:
- 4.1
-
setDefaultHeaders
public final HttpAsyncClientBuilder 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.
-
setDefaultIOReactorConfig
public final HttpAsyncClientBuilder setDefaultIOReactorConfig(org.apache.http.impl.nio.reactor.IOReactorConfig config)
Assigns defaultIOReactorConfig
.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)
method.
-
setDefaultConnectionConfig
public final HttpAsyncClientBuilder setDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)
Assigns defaultConnectionConfig
.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)
method.
-
setDefaultRequestConfig
public final HttpAsyncClientBuilder setDefaultRequestConfig(org.apache.http.client.config.RequestConfig config)
Assigns defaultRequestConfig
instance which will be used for request execution if not explicitly set in the client execution context.
-
setThreadFactory
public final HttpAsyncClientBuilder setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
AssignsThreadFactory
instance.
-
setEventHandler
public final HttpAsyncClientBuilder setEventHandler(org.apache.http.nio.NHttpClientEventHandler eventHandler)
AssignsNHttpClientEventHandler
instance.- Since:
- 4.1
-
disableConnectionState
public final HttpAsyncClientBuilder disableConnectionState()
Disables connection state tracking.
-
disableCookieManagement
public final HttpAsyncClientBuilder disableCookieManagement()
Disables state (cookie) management.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
disableAuthCaching
public final HttpAsyncClientBuilder disableAuthCaching()
Disables authentication scheme caching.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)
method.
-
useSystemProperties
public final HttpAsyncClientBuilder useSystemProperties()
Use system properties when creating and configuring default implementations.
-
split
private static java.lang.String[] split(java.lang.String s)
-
build
public CloseableHttpAsyncClient build()
-
-