Class H2AsyncClientBuilder
java.lang.Object
org.apache.hc.client5.http.impl.async.H2AsyncClientBuilder
- Direct Known Subclasses:
CachingH2AsyncClientBuilder
Builder for HTTP/2 only
CloseableHttpAsyncClient instances.
Concurrent message exchanges with the same connection route executed
with these CloseableHttpAsyncClient instances will get
automatically multiplexed over a single physical HTTP/2 connection.
When a particular component is not explicitly set this class will use its default implementation.
- Since:
- 5.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class(package private) static classprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> private booleanprivate org.apache.hc.core5.http.config.CharCodingConfigprivate org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost, ConnectionConfig> private booleanprivate org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> private CookieStoreprivate CredentialsProviderprivate Collection<? extends org.apache.hc.core5.http.Header> private RequestConfigprivate DnsResolverprivate booleanprivate org.apache.hc.core5.http2.config.H2Configprivate org.apache.hc.core5.reactor.IOReactorConfigprivate org.apache.hc.core5.function.Callback<Exception> private org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> private org.apache.hc.core5.reactor.IOSessionListenerprivate org.apache.hc.core5.util.TimeValueprivate booleanprivate AuthenticationStrategyprivate booleanprivate RedirectStrategyprivate HttpRequestRetryStrategyprivate HttpRoutePlannerprivate SchemePortResolverprivate booleanprivate AuthenticationStrategyprivate ThreadFactoryprivate org.apache.hc.core5.http.nio.ssl.TlsStrategyprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCloseable(Closeable closeable) Adds to the list ofCloseableresources to be managed by the client.final H2AsyncClientBuilderaddExecInterceptorAfter(String existing, String name, AsyncExecChainHandler interceptor) Adds this execution interceptor after interceptor with the given name.final H2AsyncClientBuilderaddExecInterceptorBefore(String existing, String name, AsyncExecChainHandler interceptor) Adds this execution interceptor before an existing interceptor.final H2AsyncClientBuilderaddExecInterceptorFirst(String name, AsyncExecChainHandler interceptor) Add an interceptor to the head of the processing list.final H2AsyncClientBuilderaddExecInterceptorLast(String name, AsyncExecChainHandler interceptor) Add an interceptor to the tail of the processing list.final H2AsyncClientBuilderaddRequestInterceptorFirst(org.apache.hc.core5.http.HttpRequestInterceptor interceptor) Adds this protocol interceptor to the head of the protocol processing list.final H2AsyncClientBuilderaddRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor) Adds this protocol interceptor to the tail of the protocol processing list.final H2AsyncClientBuilderaddResponseInterceptorFirst(org.apache.hc.core5.http.HttpResponseInterceptor interceptor) Adds this protocol interceptor to the head of the protocol processing list.final H2AsyncClientBuilderaddResponseInterceptorLast(org.apache.hc.core5.http.HttpResponseInterceptor interceptor) Adds this protocol interceptor to the tail of the protocol processing list.build()static H2AsyncClientBuildercreate()protected voidcustomizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition) Request exec chain customization and extension.final H2AsyncClientBuilderDisables authentication scheme caching.final H2AsyncClientBuilderDisables automatic request recovery and re-execution.final H2AsyncClientBuilderDisables state (cookie) management.final H2AsyncClientBuilderDisables automatic redirect handling.final H2AsyncClientBuilderDisable installing the HTTP/2 Priority header interceptor by default.final H2AsyncClientBuilderevictIdleConnections(org.apache.hc.core5.util.TimeValue maxIdleTime) Makes this instance of HttpClient proactively evict idle connections from the connection pool using a background thread.private static StringgetProperty(String key, String defaultValue) final H2AsyncClientBuilderreplaceExecInterceptor(String existing, AsyncExecChainHandler interceptor) Replace an existing interceptor with the given name with new interceptor.final H2AsyncClientBuildersetCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig) SetsCharCodingConfigconfiguration.final H2AsyncClientBuildersetConnectionConfigResolver(org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost, ConnectionConfig> connectionConfigResolver) SetsResolverforConnectionConfigon a per host basis.final H2AsyncClientBuildersetDefaultAuthSchemeRegistry(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.final H2AsyncClientBuildersetDefaultConnectionConfig(ConnectionConfig connectionConfig) Sets the sameConnectionConfigfor all hosts.final H2AsyncClientBuildersetDefaultCookieSpecRegistry(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.final H2AsyncClientBuildersetDefaultCookieStore(CookieStore cookieStore) Sets defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.final H2AsyncClientBuildersetDefaultCredentialsProvider(CredentialsProvider credentialsProvider) Sets defaultCredentialsProviderinstance which will be used for request execution if not explicitly set in the client execution context.final H2AsyncClientBuildersetDefaultHeaders(Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders) Sets default request header values.final H2AsyncClientBuildersetDefaultRequestConfig(RequestConfig config) Sets defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.final H2AsyncClientBuildersetDnsResolver(DnsResolver dnsResolver) SetsDnsResolverinstance.final H2AsyncClientBuildersetH2Config(org.apache.hc.core5.http2.config.H2Config h2Config) SetsH2Configconfiguration.final H2AsyncClientBuildersetIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig) SetsIOReactorConfigconfiguration.final H2AsyncClientBuildersetIoReactorExceptionCallback(org.apache.hc.core5.function.Callback<Exception> ioReactorExceptionCallback) Sets the callback that will be invoked when the client's IOReactor encounters an uncaught exception.final H2AsyncClientBuildersetIoSessionDecorator(org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator) Sets theIOSessionDecoratorthat will be use with the client's IOReactor.final H2AsyncClientBuildersetIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener) SetsIOSessionListenerlistener.final H2AsyncClientBuildersetProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy) SetsAuthenticationStrategyinstance for proxy authentication.setRedirectStrategy(RedirectStrategy redirectStrategy) SetsRedirectStrategyinstance.final H2AsyncClientBuildersetRetryStrategy(HttpRequestRetryStrategy retryStrategy) SetsHttpRequestRetryStrategyinstance.final H2AsyncClientBuildersetRoutePlanner(HttpRoutePlanner routePlanner) SetsHttpRoutePlannerinstance.final H2AsyncClientBuildersetSchemePortResolver(SchemePortResolver schemePortResolver) SetsSchemePortResolverinstance.final H2AsyncClientBuildersetTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy) SetsAuthenticationStrategyinstance for target host authentication.final H2AsyncClientBuildersetThreadFactory(ThreadFactory threadFactory) SetsThreadFactoryinstance.final H2AsyncClientBuildersetTlsStrategy(org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy) SetsTlsStrategyinstance.final H2AsyncClientBuildersetUserAgent(String userAgent) SetsUser-Agentvalue.final H2AsyncClientBuilderUse system properties when creating and configuring default implementations.
-
Field Details
-
ioReactorConfig
private org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig -
ioSessionListener
private org.apache.hc.core5.reactor.IOSessionListener ioSessionListener -
h2Config
private org.apache.hc.core5.http2.config.H2Config h2Config -
charCodingConfig
private org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig -
schemePortResolver
-
targetAuthStrategy
-
proxyAuthStrategy
-
requestInterceptors
-
responseInterceptors
-
execInterceptors
-
routePlanner
-
redirectStrategy
-
retryStrategy
-
authSchemeRegistry
-
cookieSpecRegistry
-
cookieStore
-
credentialsProvider
-
userAgent
-
defaultHeaders
-
defaultRequestConfig
-
connectionConfigResolver
private org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost, ConnectionConfig> connectionConfigResolver -
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 -
dnsResolver
-
tlsStrategy
private org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy -
threadFactory
-
closeables
-
ioReactorExceptionCallback
-
ioSessionDecorator
private org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator -
priorityHeaderDisabled
private boolean priorityHeaderDisabled
-
-
Constructor Details
-
H2AsyncClientBuilder
protected H2AsyncClientBuilder()
-
-
Method Details
-
create
-
setH2Config
SetsH2Configconfiguration.- Returns:
- this instance.
-
setIOReactorConfig
public final H2AsyncClientBuilder setIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig) SetsIOReactorConfigconfiguration.- Returns:
- this instance.
-
setIOSessionListener
public final H2AsyncClientBuilder setIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener) SetsIOSessionListenerlistener.- Returns:
- this instance.
- Since:
- 5.2
-
setCharCodingConfig
public final H2AsyncClientBuilder setCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig) SetsCharCodingConfigconfiguration.- Returns:
- this instance.
-
setTargetAuthenticationStrategy
public final H2AsyncClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy) SetsAuthenticationStrategyinstance for target host authentication.- Returns:
- this instance.
-
setProxyAuthenticationStrategy
public final H2AsyncClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy) SetsAuthenticationStrategyinstance for proxy authentication.- Returns:
- this instance.
-
setIoReactorExceptionCallback
public final H2AsyncClientBuilder setIoReactorExceptionCallback(org.apache.hc.core5.function.Callback<Exception> ioReactorExceptionCallback) Sets the callback that will be invoked when the client's IOReactor encounters an uncaught exception.- Returns:
- this instance.
- Since:
- 5.2
-
setIoSessionDecorator
public final H2AsyncClientBuilder 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
-
disableRequestPriority
Disable installing the HTTP/2 Priority header interceptor by default.- Since:
- 5.6
-
addResponseInterceptorFirst
public final H2AsyncClientBuilder 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 H2AsyncClientBuilder 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 H2AsyncClientBuilder addExecInterceptorBefore(String existing, String name, AsyncExecChainHandler interceptor) Adds this execution interceptor before an existing interceptor.- Returns:
- this instance.
-
addExecInterceptorAfter
public final H2AsyncClientBuilder addExecInterceptorAfter(String existing, String name, AsyncExecChainHandler interceptor) Adds this execution interceptor after interceptor with the given name.- Returns:
- this instance.
-
replaceExecInterceptor
public final H2AsyncClientBuilder replaceExecInterceptor(String existing, AsyncExecChainHandler interceptor) Replace an existing interceptor with the given name with new interceptor.- Returns:
- this instance.
-
addExecInterceptorFirst
public final H2AsyncClientBuilder addExecInterceptorFirst(String name, AsyncExecChainHandler interceptor) Add an interceptor to the head of the processing list.- Returns:
- this instance.
-
addExecInterceptorLast
public final H2AsyncClientBuilder addExecInterceptorLast(String name, AsyncExecChainHandler interceptor) Add an interceptor to the tail of the processing list.- Returns:
- this instance.
-
addRequestInterceptorFirst
public final H2AsyncClientBuilder 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 H2AsyncClientBuilder addRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor) Adds this protocol interceptor to the tail of the protocol processing list.- Returns:
- this instance.
-
setRetryStrategy
SetsHttpRequestRetryStrategyinstance.Please note this value can be overridden by the
disableAutomaticRetries()method.- Returns:
- this instance.
-
setRedirectStrategy
SetsRedirectStrategyinstance.Please note this value can be overridden by the
disableRedirectHandling()method.- Returns:
- this instance.
-
setSchemePortResolver
SetsSchemePortResolverinstance.- Returns:
- this instance.
-
setDnsResolver
SetsDnsResolverinstance.- Returns:
- this instance.
-
setTlsStrategy
public final H2AsyncClientBuilder setTlsStrategy(org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy) SetsTlsStrategyinstance.- Returns:
- this instance.
-
setThreadFactory
SetsThreadFactoryinstance.- Returns:
- this instance.
-
setUserAgent
SetsUser-Agentvalue.- Returns:
- this instance.
-
setDefaultHeaders
public final H2AsyncClientBuilder setDefaultHeaders(Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders) Sets default request header values.- Returns:
- this instance.
-
setRoutePlanner
SetsHttpRoutePlannerinstance.- Returns:
- this instance.
-
setDefaultCredentialsProvider
public final H2AsyncClientBuilder 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 H2AsyncClientBuilder 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 H2AsyncClientBuilder 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
Sets defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.- Returns:
- this instance.
-
setDefaultRequestConfig
Sets defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.- Returns:
- this instance.
-
setConnectionConfigResolver
public final H2AsyncClientBuilder setConnectionConfigResolver(org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost, ConnectionConfig> connectionConfigResolver) SetsResolverforConnectionConfigon a per host basis.- Returns:
- this instance.
- Since:
- 5.2
-
setDefaultConnectionConfig
Sets the sameConnectionConfigfor all hosts.- Returns:
- this instance.
- Since:
- 5.2
-
useSystemProperties
Use system properties when creating and configuring default implementations.- Returns:
- this instance.
-
disableRedirectHandling
Disables automatic redirect handling.- Returns:
- this instance.
-
disableAutomaticRetries
Disables automatic request recovery and re-execution.- Returns:
- this instance.
-
disableCookieManagement
Disables state (cookie) management.- Returns:
- this instance.
-
disableAuthCaching
Disables authentication scheme caching.- Returns:
- this instance.
-
evictIdleConnections
public final H2AsyncClientBuilder 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.
-
customizeExecChain
@Internal protected void customizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition) Request exec chain customization and extension.For internal use.
-
addCloseable
-
build
-
getProperty
-