Class HttpAsyncClientBuilder
- java.lang.Object
-
- org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder
-
- Direct Known Subclasses:
CachingHttpAsyncClientBuilder
public class HttpAsyncClientBuilder extends java.lang.ObjectBuilder forCloseableHttpAsyncClientinstances that can negotiate the most optimal HTTP protocol version during theTLShandshake withALPNextension if supported by the Java runtime.Concurrent message exchanges executed by
CloseableHttpAsyncClientinstances 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 callingbuild().- http.proxyHost
- http.proxyPort
- https.proxyHost
- https.proxyPort
- http.nonProxyHosts
- http.keepAlive
- http.agent
Please note that some settings used by this class can be mutually exclusive and may not apply when building
CloseableHttpAsyncClientinstances.- Since:
- 5.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classHttpAsyncClientBuilder.ExecInterceptorEntryprivate static classHttpAsyncClientBuilder.RequestInterceptorEntryprivate static classHttpAsyncClientBuilder.ResponseInterceptorEntry
-
Field Summary
Fields Modifier and Type Field Description private booleanauthCachingDisabledprivate org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory>authSchemeRegistryprivate booleanautomaticRetriesDisabledprivate org.apache.hc.core5.http.config.CharCodingConfigcharCodingConfigprivate java.util.List<java.io.Closeable>closeablesprivate booleanconnectionStateDisabledprivate AsyncClientConnectionManagerconnManagerprivate booleanconnManagerSharedprivate booleancontentCompressionDisabledWhentruethe client skips all transparent response decompression.private java.util.LinkedHashMap<java.lang.String,java.util.function.UnaryOperator<org.apache.hc.core5.http.nio.AsyncDataConsumer>>contentDecoderMapMapsContent-Encodingtokens to decoder factories in insertion order.private booleancookieManagementDisabledprivate org.apache.hc.core5.http.config.Lookup<CookieSpecFactory>cookieSpecRegistryprivate CookieStorecookieStoreprivate CredentialsProvidercredentialsProviderprivate java.util.Collection<? extends org.apache.hc.core5.http.Header>defaultHeadersprivate RequestConfigdefaultRequestConfigprivate EarlyHintsListenerearlyHintsListenerprivate booleanevictExpiredConnectionsprivate booleanevictIdleConnectionsprivate java.util.LinkedList<HttpAsyncClientBuilder.ExecInterceptorEntry>execInterceptorsprivate org.apache.hc.core5.http.config.Http1Configh1Configprivate org.apache.hc.core5.http2.config.H2Configh2Configprivate org.apache.hc.core5.reactor.IOReactorConfigioReactorConfigprivate org.apache.hc.core5.function.Callback<java.lang.Exception>ioReactorExceptionCallbackprivate org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession>ioSessionDecoratorprivate org.apache.hc.core5.reactor.IOSessionListenerioSessionListenerprivate ConnectionKeepAliveStrategykeepAliveStrategyprivate org.apache.hc.core5.util.TimeValuemaxIdleTimeprivate booleanpriorityHeaderDisabledprivate org.apache.hc.core5.http.HttpHostproxyprivate AuthenticationStrategyproxyAuthStrategyprivate java.net.ProxySelectorproxySelectorprivate booleanredirectHandlingDisabledprivate RedirectStrategyredirectStrategyprivate java.util.LinkedList<HttpAsyncClientBuilder.RequestInterceptorEntry>requestInterceptorsprivate java.util.LinkedList<HttpAsyncClientBuilder.ResponseInterceptorEntry>responseInterceptorsprivate HttpRequestRetryStrategyretryStrategyprivate org.apache.hc.core5.http.ConnectionReuseStrategyreuseStrategyprivate HttpRoutePlannerroutePlannerprivate SchemePortResolverschemePortResolverprivate booleansystemPropertiesprivate AuthenticationStrategytargetAuthStrategyprivate java.util.concurrent.ThreadFactorythreadFactoryprivate TlsConfigtlsConfigDeprecated.TLS should be configured by the connection managerprivate java.lang.StringuserAgentprivate UserTokenHandleruserTokenHandler
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpAsyncClientBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddCloseable(java.io.Closeable closeable)Adds to the list ofCloseableresources to be managed by the client.HttpAsyncClientBuilderaddExecInterceptorAfter(java.lang.String existing, java.lang.String name, AsyncExecChainHandler interceptor)Adds this execution interceptor after interceptor with the given name.HttpAsyncClientBuilderaddExecInterceptorBefore(java.lang.String existing, java.lang.String name, AsyncExecChainHandler interceptor)Adds this execution interceptor before an existing interceptor.HttpAsyncClientBuilderaddExecInterceptorFirst(java.lang.String name, AsyncExecChainHandler interceptor)Add an interceptor to the head of the processing list.HttpAsyncClientBuilderaddExecInterceptorLast(java.lang.String name, AsyncExecChainHandler interceptor)Add an interceptor to the tail of the processing list.HttpAsyncClientBuilderaddRequestInterceptorFirst(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)Adds this protocol interceptor to the head of the protocol processing list.HttpAsyncClientBuilderaddRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)Adds this protocol interceptor to the tail of the protocol processing list.HttpAsyncClientBuilderaddResponseInterceptorFirst(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)Adds this protocol interceptor to the head of the protocol processing list.HttpAsyncClientBuilderaddResponseInterceptorLast(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)Adds this protocol interceptor to the tail of the protocol processing list.CloseableHttpAsyncClientbuild()protected java.util.function.Function<org.apache.hc.core5.http.protocol.HttpContext,HttpClientContext>contextAdaptor()static HttpAsyncClientBuildercreate()protected voidcustomizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition)Request exec chain customization and extension.HttpAsyncClientBuilderdisableAuthCaching()Disables authentication scheme caching.HttpAsyncClientBuilderdisableAutomaticRetries()Disables automatic request recovery and re-execution.HttpAsyncClientBuilderdisableConnectionState()Disables connection state tracking.HttpAsyncClientBuilderdisableContentCompression()Disables transparent response decompression for the client produced by this builder.HttpAsyncClientBuilderdisableCookieManagement()Disables state (cookie) management.HttpAsyncClientBuilderdisableRedirectHandling()Disables automatic redirect handling.HttpAsyncClientBuilderdisableRequestPriority()Disable installing the HTTP/2 Priority header interceptor by default.HttpAsyncClientBuilderevictExpiredConnections()Makes this instance of HttpClient proactively evict expired connections from the connection pool using a background thread.HttpAsyncClientBuilderevictIdleConnections(org.apache.hc.core5.util.TimeValue maxIdleTime)Makes this instance of HttpClient proactively evict idle connections from the connection pool using a background thread.AsyncClientConnectionManagergetConnManager()private java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)HttpAsyncClientBuilderreplaceExecInterceptor(java.lang.String existing, AsyncExecChainHandler interceptor)Replace an existing interceptor with the given name with new interceptor.HttpAsyncClientBuildersetCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)SetsCharCodingConfigconfiguration.HttpAsyncClientBuildersetConnectionManager(AsyncClientConnectionManager connManager)SetsAsyncClientConnectionManagerinstance.HttpAsyncClientBuildersetConnectionManagerShared(boolean shared)Defines the connection manager is to be shared by multiple client instances.HttpAsyncClientBuildersetConnectionReuseStrategy(org.apache.hc.core5.http.ConnectionReuseStrategy reuseStrategy)SetsConnectionReuseStrategyinstance.HttpAsyncClientBuildersetContentDecoderMap(java.util.LinkedHashMap<java.lang.String,java.util.function.UnaryOperator<org.apache.hc.core5.http.nio.AsyncDataConsumer>> contentDecoderMap)Replaces the current decoder registry withcontentDecoderMap.HttpAsyncClientBuildersetDefaultAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry)Sets defaultAuthSchemeregistry which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry)Sets defaultCookieSpecregistry which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultCookieStore(CookieStore cookieStore)Sets defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultCredentialsProvider(CredentialsProvider credentialsProvider)Sets defaultCredentialsProviderinstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultHeaders(java.util.Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders)Sets default request header values.HttpAsyncClientBuildersetDefaultRequestConfig(RequestConfig config)Sets defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetEarlyHintsListener(EarlyHintsListener listener)Registers a globalEarlyHintsListenerthat will be notified when the client receives103 Early Hintsinformational responses for any request executed by the built client.HttpAsyncClientBuildersetH2Config(org.apache.hc.core5.http2.config.H2Config h2Config)SetsH2Configconfiguration.HttpAsyncClientBuildersetHttp1Config(org.apache.hc.core5.http.config.Http1Config h1Config)SetsHttp1Configconfiguration.HttpAsyncClientBuildersetIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig)SetsIOReactorConfigconfiguration.HttpAsyncClientBuildersetIoReactorExceptionCallback(org.apache.hc.core5.function.Callback<java.lang.Exception> ioReactorExceptionCallback)Sets the callback that will be invoked when the client's IOReactor encounters an uncaught exception.HttpAsyncClientBuildersetIoSessionDecorator(org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator)Sets theIOSessionDecoratorthat will be use with the client's IOReactor.HttpAsyncClientBuildersetIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener)SetsIOSessionListenerlistener.HttpAsyncClientBuildersetKeepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy)SetsConnectionKeepAliveStrategyinstance.HttpAsyncClientBuildersetProxy(org.apache.hc.core5.http.HttpHost proxy)Sets default proxy value.HttpAsyncClientBuildersetProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)SetsAuthenticationStrategyinstance for proxy authentication.HttpAsyncClientBuildersetProxySelector(java.net.ProxySelector proxySelector)Sets theProxySelectorthat will be used to select the proxies to be used for establishing HTTP connections.HttpAsyncClientBuildersetRedirectStrategy(RedirectStrategy redirectStrategy)SetsRedirectStrategyinstance.HttpAsyncClientBuildersetRetryStrategy(HttpRequestRetryStrategy retryStrategy)SetsHttpRequestRetryStrategyinstance.HttpAsyncClientBuildersetRoutePlanner(HttpRoutePlanner routePlanner)SetsHttpRoutePlannerinstance.HttpAsyncClientBuildersetSchemePortResolver(SchemePortResolver schemePortResolver)SetsSchemePortResolverinstance.HttpAsyncClientBuildersetTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)SetsAuthenticationStrategyinstance for target host authentication.HttpAsyncClientBuildersetThreadFactory(java.util.concurrent.ThreadFactory threadFactory)SetsThreadFactoryinstance.HttpAsyncClientBuildersetUserAgent(java.lang.String userAgent)SetsUser-Agentvalue.HttpAsyncClientBuildersetUserTokenHandler(UserTokenHandler userTokenHandler)SetsUserTokenHandlerinstance.HttpAsyncClientBuildersetVersionPolicy(org.apache.hc.core5.http2.HttpVersionPolicy versionPolicy)Deprecated.UseTlsConfigand connection manager methodsHttpAsyncClientBuilderuseSystemProperties()Use system properties when creating and configuring default implementations.
-
-
-
Field Detail
-
tlsConfig
@Deprecated private TlsConfig tlsConfig
Deprecated.TLS should be configured by the connection manager
-
connManager
private AsyncClientConnectionManager connManager
-
connManagerShared
private boolean connManagerShared
-
ioReactorConfig
private org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig
-
ioSessionListener
private org.apache.hc.core5.reactor.IOSessionListener ioSessionListener
-
ioReactorExceptionCallback
private org.apache.hc.core5.function.Callback<java.lang.Exception> ioReactorExceptionCallback
-
h1Config
private org.apache.hc.core5.http.config.Http1Config h1Config
-
h2Config
private org.apache.hc.core5.http2.config.H2Config h2Config
-
charCodingConfig
private org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig
-
schemePortResolver
private SchemePortResolver schemePortResolver
-
keepAliveStrategy
private ConnectionKeepAliveStrategy keepAliveStrategy
-
userTokenHandler
private UserTokenHandler userTokenHandler
-
targetAuthStrategy
private AuthenticationStrategy targetAuthStrategy
-
proxyAuthStrategy
private AuthenticationStrategy proxyAuthStrategy
-
ioSessionDecorator
private org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator
-
requestInterceptors
private java.util.LinkedList<HttpAsyncClientBuilder.RequestInterceptorEntry> requestInterceptors
-
responseInterceptors
private java.util.LinkedList<HttpAsyncClientBuilder.ResponseInterceptorEntry> responseInterceptors
-
execInterceptors
private java.util.LinkedList<HttpAsyncClientBuilder.ExecInterceptorEntry> execInterceptors
-
routePlanner
private HttpRoutePlanner routePlanner
-
redirectStrategy
private RedirectStrategy redirectStrategy
-
retryStrategy
private HttpRequestRetryStrategy retryStrategy
-
reuseStrategy
private org.apache.hc.core5.http.ConnectionReuseStrategy reuseStrategy
-
authSchemeRegistry
private org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry
-
cookieSpecRegistry
private org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry
-
cookieStore
private CookieStore cookieStore
-
credentialsProvider
private CredentialsProvider credentialsProvider
-
userAgent
private java.lang.String userAgent
-
proxy
private org.apache.hc.core5.http.HttpHost proxy
-
defaultHeaders
private java.util.Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders
-
defaultRequestConfig
private RequestConfig defaultRequestConfig
-
evictExpiredConnections
private boolean evictExpiredConnections
-
evictIdleConnections
private boolean evictIdleConnections
-
maxIdleTime
private org.apache.hc.core5.util.TimeValue maxIdleTime
-
systemProperties
private boolean systemProperties
-
automaticRetriesDisabled
private boolean automaticRetriesDisabled
-
redirectHandlingDisabled
private boolean redirectHandlingDisabled
-
cookieManagementDisabled
private boolean cookieManagementDisabled
-
authCachingDisabled
private boolean authCachingDisabled
-
connectionStateDisabled
private boolean connectionStateDisabled
-
threadFactory
private java.util.concurrent.ThreadFactory threadFactory
-
closeables
private java.util.List<java.io.Closeable> closeables
-
proxySelector
private java.net.ProxySelector proxySelector
-
earlyHintsListener
private EarlyHintsListener earlyHintsListener
-
priorityHeaderDisabled
private boolean priorityHeaderDisabled
-
contentDecoderMap
private java.util.LinkedHashMap<java.lang.String,java.util.function.UnaryOperator<org.apache.hc.core5.http.nio.AsyncDataConsumer>> contentDecoderMap
MapsContent-Encodingtokens to decoder factories in insertion order.
-
contentCompressionDisabled
private boolean contentCompressionDisabled
Whentruethe client skips all transparent response decompression.
-
-
Method Detail
-
create
public static HttpAsyncClientBuilder create()
-
setVersionPolicy
@Deprecated public final HttpAsyncClientBuilder setVersionPolicy(org.apache.hc.core5.http2.HttpVersionPolicy versionPolicy)
Deprecated.UseTlsConfigand connection manager methodsSets HTTP protocol version policy.- Returns:
- this instance.
-
setHttp1Config
public final HttpAsyncClientBuilder setHttp1Config(org.apache.hc.core5.http.config.Http1Config h1Config)
SetsHttp1Configconfiguration.- Returns:
- this instance.
-
setH2Config
public final HttpAsyncClientBuilder setH2Config(org.apache.hc.core5.http2.config.H2Config h2Config)
SetsH2Configconfiguration.- Returns:
- this instance.
-
setConnectionManager
public final HttpAsyncClientBuilder setConnectionManager(AsyncClientConnectionManager connManager)
SetsAsyncClientConnectionManagerinstance.- Returns:
- this 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.- Returns:
- this instance.
-
setIOReactorConfig
public final HttpAsyncClientBuilder setIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig)
SetsIOReactorConfigconfiguration.- Returns:
- this instance.
-
setIOSessionListener
public final HttpAsyncClientBuilder setIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener)
SetsIOSessionListenerlistener.- Returns:
- this instance.
- Since:
- 5.2
-
setIoReactorExceptionCallback
public final HttpAsyncClientBuilder setIoReactorExceptionCallback(org.apache.hc.core5.function.Callback<java.lang.Exception> ioReactorExceptionCallback)
Sets the callback that will be invoked when the client's IOReactor encounters an uncaught exception.- Returns:
- this instance.
- Since:
- 5.1
-
setCharCodingConfig
public final HttpAsyncClientBuilder setCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)
SetsCharCodingConfigconfiguration.- Returns:
- this instance.
-
setConnectionReuseStrategy
public final HttpAsyncClientBuilder setConnectionReuseStrategy(org.apache.hc.core5.http.ConnectionReuseStrategy reuseStrategy)
SetsConnectionReuseStrategyinstance.Please note this strategy applies to HTTP/1.0 and HTTP/1.1 connections only
- Returns:
- this instance.
-
setKeepAliveStrategy
public final HttpAsyncClientBuilder setKeepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy)
SetsConnectionKeepAliveStrategyinstance.- Returns:
- this instance.
-
setUserTokenHandler
public final HttpAsyncClientBuilder setUserTokenHandler(UserTokenHandler userTokenHandler)
SetsUserTokenHandlerinstance.Please note this value can be overridden by the
disableConnectionState()method.- Returns:
- this instance.
-
setTargetAuthenticationStrategy
public final HttpAsyncClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)
SetsAuthenticationStrategyinstance for target host authentication.- Returns:
- this instance.
-
setProxyAuthenticationStrategy
public final HttpAsyncClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)
SetsAuthenticationStrategyinstance for proxy authentication.- Returns:
- this instance.
-
setIoSessionDecorator
public final HttpAsyncClientBuilder setIoSessionDecorator(org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator)
Sets theIOSessionDecoratorthat will be use with the client's IOReactor.- Returns:
- this instance.
- Since:
- 5.2
-
addResponseInterceptorFirst
public final HttpAsyncClientBuilder addResponseInterceptorFirst(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)
Adds this protocol interceptor to the head of the protocol processing list.- Returns:
- this instance.
-
addResponseInterceptorLast
public final HttpAsyncClientBuilder addResponseInterceptorLast(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)
Adds this protocol interceptor to the tail of the protocol processing list.- Returns:
- this instance.
-
addExecInterceptorBefore
public final HttpAsyncClientBuilder addExecInterceptorBefore(java.lang.String existing, java.lang.String name, AsyncExecChainHandler interceptor)
Adds this execution interceptor before an existing interceptor.- Returns:
- this instance.
-
addExecInterceptorAfter
public final HttpAsyncClientBuilder addExecInterceptorAfter(java.lang.String existing, java.lang.String name, AsyncExecChainHandler interceptor)
Adds this execution interceptor after interceptor with the given name.- Returns:
- this instance.
-
replaceExecInterceptor
public final HttpAsyncClientBuilder replaceExecInterceptor(java.lang.String existing, AsyncExecChainHandler interceptor)
Replace an existing interceptor with the given name with new interceptor.- Returns:
- this instance.
-
addExecInterceptorFirst
public final HttpAsyncClientBuilder addExecInterceptorFirst(java.lang.String name, AsyncExecChainHandler interceptor)
Add an interceptor to the head of the processing list.- Returns:
- this instance.
-
addExecInterceptorLast
public final HttpAsyncClientBuilder addExecInterceptorLast(java.lang.String name, AsyncExecChainHandler interceptor)
Add an interceptor to the tail of the processing list.- Returns:
- this instance.
-
addRequestInterceptorFirst
public final HttpAsyncClientBuilder addRequestInterceptorFirst(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)
Adds this protocol interceptor to the head of the protocol processing list.- Returns:
- this instance.
-
addRequestInterceptorLast
public final HttpAsyncClientBuilder addRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)
Adds this protocol interceptor to the tail of the protocol processing list.- Returns:
- this instance.
-
setRetryStrategy
public final HttpAsyncClientBuilder setRetryStrategy(HttpRequestRetryStrategy retryStrategy)
SetsHttpRequestRetryStrategyinstance.Please note this value can be overridden by the
disableAutomaticRetries()method.- Returns:
- this instance.
-
setRedirectStrategy
public HttpAsyncClientBuilder setRedirectStrategy(RedirectStrategy redirectStrategy)
SetsRedirectStrategyinstance.Please note this value can be overridden by the
disableRedirectHandling()method.- Returns:
- this instance.
-
setSchemePortResolver
public final HttpAsyncClientBuilder setSchemePortResolver(SchemePortResolver schemePortResolver)
SetsSchemePortResolverinstance.- Returns:
- this instance.
-
setThreadFactory
public final HttpAsyncClientBuilder setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
SetsThreadFactoryinstance.- Returns:
- this instance.
-
setUserAgent
public final HttpAsyncClientBuilder setUserAgent(java.lang.String userAgent)
SetsUser-Agentvalue.- Returns:
- this instance.
-
setDefaultHeaders
public final HttpAsyncClientBuilder setDefaultHeaders(java.util.Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders)
Sets default request header values.- Returns:
- this instance.
-
setProxySelector
public final HttpAsyncClientBuilder setProxySelector(java.net.ProxySelector proxySelector)
Sets theProxySelectorthat will be used to select the proxies to be used for establishing HTTP connections. If a non-null proxy selector is set, it will take precedence over the proxy settings configured in the client.- Parameters:
proxySelector- theProxySelectorto be used, or null to use the default system proxy selector.- Returns:
- this instance.
-
setProxy
public final HttpAsyncClientBuilder setProxy(org.apache.hc.core5.http.HttpHost proxy)
Sets default proxy value.Please note this value can be overridden by the
setRoutePlanner( HttpRoutePlanner)method.- Returns:
- this instance.
-
setRoutePlanner
public final HttpAsyncClientBuilder setRoutePlanner(HttpRoutePlanner routePlanner)
SetsHttpRoutePlannerinstance.- Returns:
- this instance.
-
setDefaultCredentialsProvider
public final HttpAsyncClientBuilder setDefaultCredentialsProvider(CredentialsProvider credentialsProvider)
Sets defaultCredentialsProviderinstance which will be used for request execution if not explicitly set in the client execution context.- Returns:
- this instance.
-
setDefaultAuthSchemeRegistry
public final HttpAsyncClientBuilder setDefaultAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry)
Sets defaultAuthSchemeregistry which will be used for request execution if not explicitly set in the client execution context.- Returns:
- this instance.
-
setDefaultCookieSpecRegistry
public final HttpAsyncClientBuilder setDefaultCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry)
Sets defaultCookieSpecregistry which will be used for request execution if not explicitly set in the client execution context.- Returns:
- this instance.
-
setDefaultCookieStore
public final HttpAsyncClientBuilder setDefaultCookieStore(CookieStore cookieStore)
Sets defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.- Returns:
- this instance.
-
setDefaultRequestConfig
public final HttpAsyncClientBuilder setDefaultRequestConfig(RequestConfig config)
Sets defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.- Returns:
- this instance.
-
useSystemProperties
public final HttpAsyncClientBuilder useSystemProperties()
Use system properties when creating and configuring default implementations.- Returns:
- this instance.
-
disableConnectionState
public final HttpAsyncClientBuilder disableConnectionState()
Disables connection state tracking.- Returns:
- this instance.
-
disableRedirectHandling
public final HttpAsyncClientBuilder disableRedirectHandling()
Disables automatic redirect handling.- Returns:
- this instance.
-
disableAutomaticRetries
public final HttpAsyncClientBuilder disableAutomaticRetries()
Disables automatic request recovery and re-execution.- Returns:
- this instance.
-
disableCookieManagement
public final HttpAsyncClientBuilder disableCookieManagement()
Disables state (cookie) management.- Returns:
- this instance.
-
disableAuthCaching
public final HttpAsyncClientBuilder disableAuthCaching()
Disables authentication scheme caching.- Returns:
- this instance.
-
evictExpiredConnections
public final HttpAsyncClientBuilder 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 configured to use a shared connection manager.
- Returns:
- this instance.
- See Also:
setConnectionManagerShared(boolean),ConnPoolControl.closeExpired()
-
evictIdleConnections
public final 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.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 configured to use a shared connection manager.
- 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.- Returns:
- this instance.
- See Also:
setConnectionManagerShared(boolean),ConnPoolControl.closeIdle(TimeValue)
-
setContentDecoderMap
public HttpAsyncClientBuilder setContentDecoderMap(java.util.LinkedHashMap<java.lang.String,java.util.function.UnaryOperator<org.apache.hc.core5.http.nio.AsyncDataConsumer>> contentDecoderMap)
Replaces the current decoder registry withcontentDecoderMap.The map’s insertion order defines the
Accept-Encodingpreference list sent on every request.- Parameters:
contentDecoderMap- a non-emptyLinkedHashMapwhose keys are lower-case coding tokens and whose values create a fresh wrapper consumer for each response- Returns:
thisbuilder instance- Since:
- 5.6
-
disableContentCompression
public HttpAsyncClientBuilder disableContentCompression()
Disables transparent response decompression for the client produced by this builder.- Returns:
thisbuilder instance- Since:
- 5.6
-
disableRequestPriority
@Experimental public final HttpAsyncClientBuilder disableRequestPriority()
Disable installing the HTTP/2 Priority header interceptor by default.- Since:
- 5.6
-
setEarlyHintsListener
public final HttpAsyncClientBuilder setEarlyHintsListener(EarlyHintsListener listener)
Registers a globalEarlyHintsListenerthat will be notified when the client receives103 Early Hintsinformational responses for any request executed by the built client.- Parameters:
listener- the listener to receive103 Early Hintsevents, ornullto remove the listener- Returns:
- this builder
- Since:
- 5.6
-
customizeExecChain
@Internal protected void customizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition)
Request exec chain customization and extension.For internal use.
-
addCloseable
@Internal protected void addCloseable(java.io.Closeable closeable)
Adds to the list ofCloseableresources to be managed by the client.For internal use.
-
contextAdaptor
@Internal protected java.util.function.Function<org.apache.hc.core5.http.protocol.HttpContext,HttpClientContext> contextAdaptor()
-
getConnManager
@Internal public AsyncClientConnectionManager getConnManager()
-
build
public CloseableHttpAsyncClient build()
-
getProperty
private java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
-
-