Top Description Inners Fields Constructors Methods
org.apache.hc.client5.http.impl.async

public Class HttpAsyncClientBuilder

extends Object
Class Inheritance
Imports
java.io.Closeable, java.net.ProxySelector, java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .Collection, .LinkedList, .List, java.util.concurrent.ThreadFactory, org.apache.hc.client5.http.AuthenticationStrategy, .ConnectionKeepAliveStrategy, .HttpRequestRetryStrategy, .SchemePortResolver, .UserTokenHandler, org.apache.hc.client5.http.async.AsyncExecChainHandler, org.apache.hc.client5.http.auth.AuthSchemeFactory, .CredentialsProvider, .StandardAuthScheme, org.apache.hc.client5.http.config.RequestConfig, .TlsConfig, org.apache.hc.client5.http.cookie.BasicCookieStore, .CookieSpecFactory, .CookieStore, org.apache.hc.client5.http.impl.ChainElement, .CookieSpecSupport, .DefaultAuthenticationStrategy, .DefaultClientConnectionReuseStrategy, .DefaultConnectionKeepAliveStrategy, .DefaultHttpRequestRetryStrategy, .DefaultRedirectStrategy, .DefaultSchemePortResolver, .DefaultUserTokenHandler, .IdleConnectionEvictor, .NoopUserTokenHandler, org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider, .BasicSchemeFactory, .BearerSchemeFactory, .DigestSchemeFactory, .SystemDefaultCredentialsProvider, org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder, org.apache.hc.client5.http.impl.routing.DefaultProxyRoutePlanner, .DefaultRoutePlanner, .SystemDefaultRoutePlanner, org.apache.hc.client5.http.nio.AsyncClientConnectionManager, org.apache.hc.client5.http.protocol.RedirectStrategy, .RequestAddCookies, .RequestDefaultHeaders, .RequestExpectContinue, .ResponseProcessCookies, org.apache.hc.client5.http.routing.HttpRoutePlanner, org.apache.hc.core5.annotation.Internal, org.apache.hc.core5.concurrent.DefaultThreadFactory, org.apache.hc.core5.function.Callback, .Decorator, org.apache.hc.core5.http.ConnectionReuseStrategy, .Header, .HttpHost, .HttpRequestInterceptor, .HttpResponseInterceptor, org.apache.hc.core5.http.config.CharCodingConfig, .Http1Config, .Lookup, .NamedElementChain, .RegistryBuilder, org.apache.hc.core5.http.nio.command.ShutdownCommand, org.apache.hc.core5.http.protocol.DefaultHttpProcessor, .HttpProcessor, .HttpProcessorBuilder, .RequestTargetHost, .RequestUserAgent, org.apache.hc.core5.http2.HttpVersionPolicy, org.apache.hc.core5.http2.config.H2Config, org.apache.hc.core5.http2.protocol.H2RequestConnControl, .H2RequestContent, .H2RequestTargetHost, org.apache.hc.core5.io.CloseMode, org.apache.hc.core5.pool.ConnPoolControl, org.apache.hc.core5.reactor.Command, .DefaultConnectingIOReactor, .IOEventHandlerFactory, .IOReactorConfig, .IOSession, .IOSessionListener, org.apache.hc.core5.util.Args, .TimeValue, .VersionInfo

Builder for 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.

Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private boolean
private Lookup<AuthSchemeFactory>
private boolean
private CharCodingConfig
private List<Closeable>
private boolean
private AsyncClientConnectionManager
private boolean
private boolean
private Lookup<CookieSpecFactory>
private CookieStore
private CredentialsProvider
private Collection<? extends Header>
private RequestConfig
private boolean
private boolean
private LinkedList<HttpAsyncClientBuilder.ExecInterceptorEntry>
private Http1Config
private H2Config
private IOReactorConfig
private Callback<Exception>
private Decorator<IOSession>
private IOSessionListener
private ConnectionKeepAliveStrategy
private TimeValue
private HttpHost
private AuthenticationStrategy
private ProxySelector
private boolean
private RedirectStrategy
private LinkedList<HttpAsyncClientBuilder.RequestInterceptorEntry>
private LinkedList<HttpAsyncClientBuilder.ResponseInterceptorEntry>
private HttpRequestRetryStrategy
private ConnectionReuseStrategy
private HttpRoutePlanner
private SchemePortResolver
private boolean
private AuthenticationStrategy
private ThreadFactory
private TlsConfig
tlsConfig

Deprecated TLS should be configured by the connection manager
private String
private UserTokenHandler

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected void
addCloseable(final Closeable closeable)

Adds to the list of Closeable resources to be managed by the client.

public final HttpAsyncClientBuilder
addExecInterceptorAfter(final String existing, final String name, final AsyncExecChainHandler interceptor)

Adds this execution interceptor after interceptor with the given name.

public final HttpAsyncClientBuilder
addExecInterceptorBefore(final String existing, final String name, final AsyncExecChainHandler interceptor)

Adds this execution interceptor before an existing interceptor.

public final HttpAsyncClientBuilder
addExecInterceptorFirst(final String name, final AsyncExecChainHandler interceptor)

Add an interceptor to the head of the processing list.

public final HttpAsyncClientBuilder
addExecInterceptorLast(final String name, final AsyncExecChainHandler interceptor)

Add an interceptor to the tail of the processing list.

public final HttpAsyncClientBuilder
addRequestInterceptorFirst(final HttpRequestInterceptor interceptor)

Adds this protocol interceptor to the head of the protocol processing list.

public final HttpAsyncClientBuilder
addRequestInterceptorLast(final HttpRequestInterceptor interceptor)

Adds this protocol interceptor to the tail of the protocol processing list.

public final HttpAsyncClientBuilder
addResponseInterceptorFirst(final HttpResponseInterceptor interceptor)

Adds this protocol interceptor to the head of the protocol processing list.

public final HttpAsyncClientBuilder
addResponseInterceptorLast(final HttpResponseInterceptor interceptor)

Adds this protocol interceptor to the tail of the protocol processing list.

public CloseableHttpAsyncClient
public static HttpAsyncClientBuilder
protected void
customizeExecChain(final NamedElementChain<AsyncExecChainHandler> execChainDefinition)

Request exec chain customization and extension.

public final HttpAsyncClientBuilder
disableAuthCaching()

Disables authentication scheme caching.

public final HttpAsyncClientBuilder
disableAutomaticRetries()

Disables automatic request recovery and re-execution.

public final HttpAsyncClientBuilder
disableConnectionState()

Disables connection state tracking.

public final HttpAsyncClientBuilder
disableCookieManagement()

Disables state (cookie) management.

public final HttpAsyncClientBuilder
disableRedirectHandling()

Disables automatic redirect handling.

public final HttpAsyncClientBuilder
evictExpiredConnections()

Makes this instance of HttpClient proactively evict expired connections from the connection pool using a background thread.

public final HttpAsyncClientBuilder
evictIdleConnections(final TimeValue
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.
maxIdleTime
)

Makes this instance of HttpClient proactively evict idle connections from the connection pool using a background thread.

private String
getProperty(final String key, final String defaultValue)

public final HttpAsyncClientBuilder
replaceExecInterceptor(final String existing, final AsyncExecChainHandler interceptor)

Replace an existing interceptor with the given name with new interceptor.

public final HttpAsyncClientBuilder
setCharCodingConfig(final CharCodingConfig charCodingConfig)

Sets CharCodingConfig configuration.

public final HttpAsyncClientBuilder
public final HttpAsyncClientBuilder
setConnectionManagerShared(final boolean
defines whether or not the connection manager can be shared by multiple clients.
shared
)

Defines the connection manager is to be shared by multiple client instances.

public final HttpAsyncClientBuilder
public final HttpAsyncClientBuilder
setDefaultAuthSchemeRegistry(final Lookup<AuthSchemeFactory> authSchemeRegistry)

Assigns default org.apache.hc.client5.http.auth.AuthScheme registry which will be used for request execution if not explicitly set in the client execution context.

public final HttpAsyncClientBuilder
setDefaultCookieSpecRegistry(final Lookup<CookieSpecFactory> cookieSpecRegistry)

Assigns default org.apache.hc.client5.http.cookie.CookieSpec registry which will be used for request execution if not explicitly set in the client execution context.

public final HttpAsyncClientBuilder
setDefaultCookieStore(final CookieStore cookieStore)

Assigns default CookieStore instance which will be used for request execution if not explicitly set in the client execution context.

public final HttpAsyncClientBuilder
setDefaultCredentialsProvider(final CredentialsProvider credentialsProvider)

Assigns default CredentialsProvider instance which will be used for request execution if not explicitly set in the client execution context.

public final HttpAsyncClientBuilder
setDefaultHeaders(final Collection<? extends Header> defaultHeaders)

Assigns default request header values.

public final HttpAsyncClientBuilder
setDefaultRequestConfig(final RequestConfig config)

Assigns default RequestConfig instance which will be used for request execution if not explicitly set in the client execution context.

public final HttpAsyncClientBuilder
setH2Config(final H2Config h2Config)

Sets H2Config configuration.

public final HttpAsyncClientBuilder
setHttp1Config(final Http1Config h1Config)

Sets Http1Config configuration.

public final HttpAsyncClientBuilder
setIOReactorConfig(final IOReactorConfig ioReactorConfig)

Sets IOReactorConfig configuration.

public final HttpAsyncClientBuilder
setIoReactorExceptionCallback(final Callback<Exception> ioReactorExceptionCallback)

Sets the callback that will be invoked when the client's IOReactor encounters an uncaught exception.

public final HttpAsyncClientBuilder
setIoSessionDecorator(final Decorator<IOSession> ioSessionDecorator)

Sets the IOSession Decorator that will be use with the client's IOReactor.

public final HttpAsyncClientBuilder
setIOSessionListener(final IOSessionListener ioSessionListener)

Sets IOSessionListener listener.

public final HttpAsyncClientBuilder
public final HttpAsyncClientBuilder
setProxy(final HttpHost proxy)

Assigns default proxy value.

public final HttpAsyncClientBuilder
setProxyAuthenticationStrategy(final AuthenticationStrategy proxyAuthStrategy)

Assigns AuthenticationStrategy instance for proxy authentication.

public final HttpAsyncClientBuilder

Returns:

this HttpAsyncClientBuilder instance, to allow for method chaining.
setProxySelector
(final ProxySelector
the java.net.ProxySelector to be used, or null to use the default system proxy selector.
proxySelector
)

Sets the java.net.ProxySelector that will be used to select the proxies to be used for establishing HTTP connections.

public HttpAsyncClientBuilder
setRedirectStrategy(final RedirectStrategy redirectStrategy)

Assigns RedirectStrategy instance.

public final HttpAsyncClientBuilder
public final HttpAsyncClientBuilder
setRoutePlanner(final HttpRoutePlanner routePlanner)

Assigns HttpRoutePlanner instance.

public final HttpAsyncClientBuilder
setSchemePortResolver(final SchemePortResolver schemePortResolver)

Assigns SchemePortResolver instance.

public final HttpAsyncClientBuilder
setTargetAuthenticationStrategy(final AuthenticationStrategy targetAuthStrategy)

Assigns AuthenticationStrategy instance for target host authentication.

public final HttpAsyncClientBuilder
setThreadFactory(final ThreadFactory threadFactory)

Assigns ThreadFactory instance.

public final HttpAsyncClientBuilder
setUserAgent(final String userAgent)

Assigns User-Agent value.

public final HttpAsyncClientBuilder
setUserTokenHandler(final UserTokenHandler userTokenHandler)

Assigns UserTokenHandler instance.

public final HttpAsyncClientBuilder
setVersionPolicy(final HttpVersionPolicy versionPolicy)

Deprecated Use TlsConfig and connection manager methods
Sets HTTP protocol version policy.
public final HttpAsyncClientBuilder
useSystemProperties()

Use system properties when creating and configuring default implementations.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait