Class HttpAsyncClientBuilder
- java.lang.Object
-
- org.apache.http.impl.nio.client.HttpAsyncClientBuilder
-
public class HttpAsyncClientBuilder extends Object
Builder forCloseableHttpAsyncClientinstances.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
CloseableHttpAsyncClientinstances.- Since:
- 4.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpAsyncClientBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HttpAsyncClientBuilderaddInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)Adds this protocol interceptor to the head of the protocol processing list.HttpAsyncClientBuilderaddInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)Adds this protocol interceptor to the head of the protocol processing list.HttpAsyncClientBuilderaddInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)Adds this protocol interceptor to the tail of the protocol processing list.HttpAsyncClientBuilderaddInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)Adds this protocol interceptor to the tail of the protocol processing list.CloseableHttpAsyncClientbuild()static HttpAsyncClientBuildercreate()HttpAsyncClientBuilderdisableAuthCaching()Disables authentication scheme caching.HttpAsyncClientBuilderdisableConnectionState()Disables connection state tracking.HttpAsyncClientBuilderdisableCookieManagement()Disables state (cookie) management.HttpAsyncClientBuildersetConnectionManager(NHttpClientConnectionManager connManager)AssignsNHttpClientConnectionManagerinstance.HttpAsyncClientBuildersetConnectionManagerShared(boolean shared)Defines the connection manager is to be shared by multiple client instances.HttpAsyncClientBuildersetConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)AssignsConnectionReuseStrategyinstance.HttpAsyncClientBuildersetDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry)Assigns defaultAuthSchemeregistry which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)Assigns defaultConnectionConfig.HttpAsyncClientBuildersetDefaultCookieSpecRegistry(org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry)Assigns defaultCookieSpecregistry which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)Assigns defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)Assigns defaultCredentialsProviderinstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultHeaders(Collection<? extends org.apache.http.Header> defaultHeaders)Assigns default request header values.HttpAsyncClientBuildersetDefaultIOReactorConfig(org.apache.http.impl.nio.reactor.IOReactorConfig config)Assigns defaultIOReactorConfig.HttpAsyncClientBuildersetDefaultRequestConfig(org.apache.http.client.config.RequestConfig config)Assigns defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetEventHandler(org.apache.http.nio.NHttpClientEventHandler eventHandler)AssignsNHttpClientEventHandlerinstance.HttpAsyncClientBuildersetHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)Deprecated.HttpAsyncClientBuildersetHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)AssignsHttpProcessorinstance.HttpAsyncClientBuildersetKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)AssignsConnectionKeepAliveStrategyinstance.HttpAsyncClientBuildersetMaxConnPerRoute(int maxConnPerRoute)Assigns maximum connection per route value.HttpAsyncClientBuildersetMaxConnTotal(int maxConnTotal)Assigns maximum total connection value.HttpAsyncClientBuildersetProxy(org.apache.http.HttpHost proxy)Assigns default proxy value.HttpAsyncClientBuildersetProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy proxyAuthStrategy)AssignsAuthenticationStrategyinstance for target host authentication.HttpAsyncClientBuildersetPublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher)Assigns file containing public suffix matcher.HttpAsyncClientBuildersetRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)AssignsRedirectStrategyinstance.HttpAsyncClientBuildersetRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)AssignsHttpRoutePlannerinstance.HttpAsyncClientBuildersetSchemePortResolver(org.apache.http.conn.SchemePortResolver schemePortResolver)AssignsSchemePortResolverinstance.HttpAsyncClientBuildersetSSLContext(SSLContext sslcontext)AssignsSSLContextinstance.HttpAsyncClientBuildersetSSLHostnameVerifier(HostnameVerifier hostnameVerifier)AssignsHostnameVerifierinstance.HttpAsyncClientBuildersetSSLStrategy(SchemeIOSessionStrategy strategy)AssignsSchemeIOSessionStrategyinstance.HttpAsyncClientBuildersetTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy targetAuthStrategy)AssignsAuthenticationStrategyinstance for proxy authentication.HttpAsyncClientBuildersetThreadFactory(ThreadFactory threadFactory)AssignsThreadFactoryinstance.HttpAsyncClientBuildersetUserAgent(String userAgent)AssignsUser-Agentvalue.HttpAsyncClientBuildersetUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)AssignsUserTokenHandlerinstance.HttpAsyncClientBuilderuseSystemProperties()Use system properties when creating and configuring default implementations.
-
-
-
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)
AssignsNHttpClientConnectionManagerinstance.
-
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)
AssignsSchemePortResolverinstance.
-
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)
AssignsConnectionReuseStrategyinstance.
-
setKeepAliveStrategy
public final HttpAsyncClientBuilder setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
AssignsConnectionKeepAliveStrategyinstance.
-
setUserTokenHandler
public final HttpAsyncClientBuilder setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
AssignsUserTokenHandlerinstance.Please note this value can be overridden by the
disableConnectionState()method.
-
setTargetAuthenticationStrategy
public final HttpAsyncClientBuilder setTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy targetAuthStrategy)
AssignsAuthenticationStrategyinstance for proxy authentication.
-
setProxyAuthenticationStrategy
public final HttpAsyncClientBuilder setProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy proxyAuthStrategy)
AssignsAuthenticationStrategyinstance for target host authentication.
-
setHttpProcessor
public final HttpAsyncClientBuilder setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
AssignsHttpProcessorinstance.
-
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)
AssignsHttpRoutePlannerinstance.
-
setRedirectStrategy
public final HttpAsyncClientBuilder setRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)
AssignsRedirectStrategyinstance.
-
setDefaultCookieStore
public final HttpAsyncClientBuilder setDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)
Assigns defaultCookieStoreinstance 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 defaultCredentialsProviderinstance 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 defaultAuthSchemeregistry 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 defaultCookieSpecregistry which will be used for request execution if not explicitly set in the client execution context.
-
setUserAgent
public final HttpAsyncClientBuilder setUserAgent(String userAgent)
AssignsUser-Agentvalue.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)
AssignsSchemeIOSessionStrategyinstance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)method.
-
setSSLContext
public final HttpAsyncClientBuilder setSSLContext(SSLContext sslcontext)
AssignsSSLContextinstance.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.AssignsX509HostnameVerifierinstance.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(HostnameVerifier hostnameVerifier)
AssignsHostnameVerifierinstance.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(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 defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.
-
setThreadFactory
public final HttpAsyncClientBuilder setThreadFactory(ThreadFactory threadFactory)
AssignsThreadFactoryinstance.
-
setEventHandler
public final HttpAsyncClientBuilder setEventHandler(org.apache.http.nio.NHttpClientEventHandler eventHandler)
AssignsNHttpClientEventHandlerinstance.- 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.
-
build
public CloseableHttpAsyncClient build()
-
-