public class HttpAsyncClientBuilder extends Object
CloseableHttpAsyncClient instances that can negotiate
 the most optimal HTTP protocol version during the TLS handshake
 with ALPN extension if supported by the Java runtime.
 
 Concurrent message exchanges executed by CloseableHttpAsyncClient
 instances created with this builder will get automatically assigned to
 separate connections leased from the connection pool.
 
 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 calling
 build().
 
 Please note that some settings used by this class can be mutually
 exclusive and may not apply when building CloseableHttpAsyncClient
 instances.
 
| Modifier | Constructor and Description | 
|---|---|
| protected  | HttpAsyncClientBuilder() | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | addCloseable(Closeable closeable)Adds to the list of  Closeableresources to be managed by the client. | 
| HttpAsyncClientBuilder | addExecInterceptorAfter(String existing,
                       String name,
                       AsyncExecChainHandler interceptor)Adds this execution interceptor after interceptor with the given name. | 
| HttpAsyncClientBuilder | addExecInterceptorBefore(String existing,
                        String name,
                        AsyncExecChainHandler interceptor)Adds this execution interceptor before an existing interceptor. | 
| HttpAsyncClientBuilder | addExecInterceptorFirst(String name,
                       AsyncExecChainHandler interceptor)Add an interceptor to the head of the processing list. | 
| HttpAsyncClientBuilder | addExecInterceptorLast(String name,
                      AsyncExecChainHandler interceptor)Add an interceptor to the tail of the processing list. | 
| HttpAsyncClientBuilder | addRequestInterceptorFirst(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)Adds this protocol interceptor to the head of the protocol processing list. | 
| HttpAsyncClientBuilder | addRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)Adds this protocol interceptor to the tail of the protocol processing list. | 
| HttpAsyncClientBuilder | addResponseInterceptorFirst(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)Adds this protocol interceptor to the head of the protocol processing list. | 
| HttpAsyncClientBuilder | addResponseInterceptorLast(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)Adds this protocol interceptor to the tail of the protocol processing list. | 
| CloseableHttpAsyncClient | build() | 
| static HttpAsyncClientBuilder | create() | 
| protected void | customizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition)Request exec chain customization and extension. | 
| HttpAsyncClientBuilder | disableAuthCaching()Disables authentication scheme caching. | 
| HttpAsyncClientBuilder | disableAutomaticRetries()Disables automatic request recovery and re-execution. | 
| HttpAsyncClientBuilder | disableConnectionState()Disables connection state tracking. | 
| HttpAsyncClientBuilder | disableCookieManagement()Disables state (cookie) management. | 
| HttpAsyncClientBuilder | disableRedirectHandling()Disables automatic redirect handling. | 
| HttpAsyncClientBuilder | evictExpiredConnections()Makes this instance of HttpClient proactively evict expired connections from the
 connection pool using a background thread. | 
| HttpAsyncClientBuilder | evictIdleConnections(org.apache.hc.core5.util.TimeValue maxIdleTime)Makes this instance of HttpClient proactively evict idle connections from the
 connection pool using a background thread. | 
| HttpAsyncClientBuilder | replaceExecInterceptor(String existing,
                      AsyncExecChainHandler interceptor)Replace an existing interceptor with the given name with new interceptor. | 
| HttpAsyncClientBuilder | setCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)Sets  CharCodingConfigconfiguration. | 
| HttpAsyncClientBuilder | setConnectionManager(AsyncClientConnectionManager connManager)Assigns  AsyncClientConnectionManagerinstance. | 
| HttpAsyncClientBuilder | setConnectionManagerShared(boolean shared)Defines the connection manager is to be shared by multiple
 client instances. | 
| HttpAsyncClientBuilder | setConnectionReuseStrategy(org.apache.hc.core5.http.ConnectionReuseStrategy reuseStrategy)Assigns  ConnectionReuseStrategyinstance. | 
| HttpAsyncClientBuilder | setDefaultAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry)Assigns default  AuthSchemeregistry which will
 be used for request execution if not explicitly set in the client execution
 context. | 
| HttpAsyncClientBuilder | setDefaultCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry)Assigns default  CookieSpecregistry
 which will be used for request execution if not explicitly set in the client
 execution context. | 
| HttpAsyncClientBuilder | setDefaultCookieStore(CookieStore cookieStore)Assigns default  CookieStoreinstance which will be used for
 request execution if not explicitly set in the client execution context. | 
| HttpAsyncClientBuilder | setDefaultCredentialsProvider(CredentialsProvider credentialsProvider)Assigns default  CredentialsProviderinstance which will be used
 for request execution if not explicitly set in the client execution
 context. | 
| HttpAsyncClientBuilder | setDefaultHeaders(Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders)Assigns default request header values. | 
| HttpAsyncClientBuilder | setDefaultRequestConfig(RequestConfig config)Assigns default  RequestConfiginstance which will be used
 for request execution if not explicitly set in the client execution
 context. | 
| HttpAsyncClientBuilder | setH2Config(org.apache.hc.core5.http2.config.H2Config h2Config)Sets  H2Configconfiguration. | 
| HttpAsyncClientBuilder | setHttp1Config(org.apache.hc.core5.http.config.Http1Config h1Config)Sets  Http1Configconfiguration. | 
| HttpAsyncClientBuilder | setIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig)Sets  IOReactorConfigconfiguration. | 
| HttpAsyncClientBuilder | setKeepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy)Assigns  ConnectionKeepAliveStrategyinstance. | 
| HttpAsyncClientBuilder | setProxy(org.apache.hc.core5.http.HttpHost proxy)Assigns default proxy value. | 
| HttpAsyncClientBuilder | setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)Assigns  AuthenticationStrategyinstance for proxy
 authentication. | 
| HttpAsyncClientBuilder | setRedirectStrategy(RedirectStrategy redirectStrategy)Assigns  RedirectStrategyinstance. | 
| HttpAsyncClientBuilder | setRetryStrategy(HttpRequestRetryStrategy retryStrategy)Assigns  HttpRequestRetryStrategyinstance. | 
| HttpAsyncClientBuilder | setRoutePlanner(HttpRoutePlanner routePlanner)Assigns  HttpRoutePlannerinstance. | 
| HttpAsyncClientBuilder | setSchemePortResolver(SchemePortResolver schemePortResolver)Assigns  SchemePortResolverinstance. | 
| HttpAsyncClientBuilder | setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)Assigns  AuthenticationStrategyinstance for target
 host authentication. | 
| HttpAsyncClientBuilder | setThreadFactory(ThreadFactory threadFactory)Assigns  ThreadFactoryinstance. | 
| HttpAsyncClientBuilder | setUserAgent(String userAgent)Assigns  User-Agentvalue. | 
| HttpAsyncClientBuilder | setUserTokenHandler(UserTokenHandler userTokenHandler)Assigns  UserTokenHandlerinstance. | 
| HttpAsyncClientBuilder | setVersionPolicy(org.apache.hc.core5.http2.HttpVersionPolicy versionPolicy)Sets HTTP protocol version policy. | 
| HttpAsyncClientBuilder | useSystemProperties()Use system properties when creating and configuring default
 implementations. | 
public static HttpAsyncClientBuilder create()
public final HttpAsyncClientBuilder setVersionPolicy(org.apache.hc.core5.http2.HttpVersionPolicy versionPolicy)
public final HttpAsyncClientBuilder setHttp1Config(org.apache.hc.core5.http.config.Http1Config h1Config)
Http1Config configuration.public final HttpAsyncClientBuilder setH2Config(org.apache.hc.core5.http2.config.H2Config h2Config)
H2Config configuration.public final HttpAsyncClientBuilder setConnectionManager(AsyncClientConnectionManager connManager)
AsyncClientConnectionManager instance.public final HttpAsyncClientBuilder setConnectionManagerShared(boolean shared)
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.
shared - defines whether or not the connection manager can be shared
  by multiple clients.public final HttpAsyncClientBuilder setIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig)
IOReactorConfig configuration.public final HttpAsyncClientBuilder setCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)
CharCodingConfig configuration.public final HttpAsyncClientBuilder setConnectionReuseStrategy(org.apache.hc.core5.http.ConnectionReuseStrategy reuseStrategy)
ConnectionReuseStrategy instance.
 Please note this strategy applies to HTTP/1.0 and HTTP/1.1 connections only
public final HttpAsyncClientBuilder setKeepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy)
ConnectionKeepAliveStrategy instance.public final HttpAsyncClientBuilder setUserTokenHandler(UserTokenHandler userTokenHandler)
UserTokenHandler instance.
 
 Please note this value can be overridden by the disableConnectionState()
 method.
 
public final HttpAsyncClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)
AuthenticationStrategy instance for target
 host authentication.public final HttpAsyncClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)
AuthenticationStrategy instance for proxy
 authentication.public final HttpAsyncClientBuilder addResponseInterceptorFirst(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)
public final HttpAsyncClientBuilder addResponseInterceptorLast(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)
public final HttpAsyncClientBuilder addExecInterceptorBefore(String existing, String name, AsyncExecChainHandler interceptor)
public final HttpAsyncClientBuilder addExecInterceptorAfter(String existing, String name, AsyncExecChainHandler interceptor)
public final HttpAsyncClientBuilder replaceExecInterceptor(String existing, AsyncExecChainHandler interceptor)
public final HttpAsyncClientBuilder addExecInterceptorFirst(String name, AsyncExecChainHandler interceptor)
public final HttpAsyncClientBuilder addExecInterceptorLast(String name, AsyncExecChainHandler interceptor)
public final HttpAsyncClientBuilder addRequestInterceptorFirst(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)
public final HttpAsyncClientBuilder addRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)
public final HttpAsyncClientBuilder setRetryStrategy(HttpRequestRetryStrategy retryStrategy)
HttpRequestRetryStrategy instance.
 
 Please note this value can be overridden by the disableAutomaticRetries()
 method.
public HttpAsyncClientBuilder setRedirectStrategy(RedirectStrategy redirectStrategy)
RedirectStrategy instance.
 
 Please note this value can be overridden by the disableRedirectHandling()
 method.
 
public final HttpAsyncClientBuilder setSchemePortResolver(SchemePortResolver schemePortResolver)
SchemePortResolver instance.public final HttpAsyncClientBuilder setThreadFactory(ThreadFactory threadFactory)
ThreadFactory instance.public final HttpAsyncClientBuilder setUserAgent(String userAgent)
User-Agent value.public final HttpAsyncClientBuilder setDefaultHeaders(Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders)
public final HttpAsyncClientBuilder setProxy(org.apache.hc.core5.http.HttpHost proxy)
 Please note this value can be overridden by the setRoutePlanner(
   HttpRoutePlanner) method.
public final HttpAsyncClientBuilder setRoutePlanner(HttpRoutePlanner routePlanner)
HttpRoutePlanner instance.public final HttpAsyncClientBuilder setDefaultCredentialsProvider(CredentialsProvider credentialsProvider)
CredentialsProvider instance which will be used
 for request execution if not explicitly set in the client execution
 context.public final HttpAsyncClientBuilder setDefaultAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry)
AuthScheme registry which will
 be used for request execution if not explicitly set in the client execution
 context.public final HttpAsyncClientBuilder setDefaultCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry)
CookieSpec registry
 which will be used for request execution if not explicitly set in the client
 execution context.public final HttpAsyncClientBuilder setDefaultCookieStore(CookieStore cookieStore)
CookieStore instance which will be used for
 request execution if not explicitly set in the client execution context.public final HttpAsyncClientBuilder setDefaultRequestConfig(RequestConfig config)
RequestConfig instance which will be used
 for request execution if not explicitly set in the client execution
 context.public final HttpAsyncClientBuilder useSystemProperties()
public final HttpAsyncClientBuilder disableConnectionState()
public final HttpAsyncClientBuilder disableRedirectHandling()
public final HttpAsyncClientBuilder disableAutomaticRetries()
public final HttpAsyncClientBuilder disableCookieManagement()
public final HttpAsyncClientBuilder disableAuthCaching()
public final HttpAsyncClientBuilder evictExpiredConnections()
 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.
setConnectionManagerShared(boolean), 
ConnPoolControl.closeExpired()public final HttpAsyncClientBuilder evictIdleConnections(org.apache.hc.core5.util.TimeValue maxIdleTime)
 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.
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.setConnectionManagerShared(boolean), 
ConnPoolControl.closeIdle(TimeValue)@Internal protected void customizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition)
For internal use.
@Internal protected void addCloseable(Closeable closeable)
Closeable resources to be managed by the client.
 For internal use.
public CloseableHttpAsyncClient build()
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.