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 class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private org.apache.hc.core5.http.config.Lookup
<AuthSchemeFactory> private boolean
private org.apache.hc.core5.http.config.CharCodingConfig
private org.apache.hc.core5.function.Resolver
<org.apache.hc.core5.http.HttpHost, ConnectionConfig> private boolean
private org.apache.hc.core5.http.config.Lookup
<CookieSpecFactory> private CookieStore
private CredentialsProvider
private Collection
<? extends org.apache.hc.core5.http.Header> private RequestConfig
private DnsResolver
private boolean
private org.apache.hc.core5.http2.config.H2Config
private org.apache.hc.core5.reactor.IOReactorConfig
private 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.IOSessionListener
private org.apache.hc.core5.util.TimeValue
private AuthenticationStrategy
private boolean
private RedirectStrategy
private HttpRequestRetryStrategy
private HttpRoutePlanner
private SchemePortResolver
private boolean
private AuthenticationStrategy
private ThreadFactory
private org.apache.hc.core5.http.nio.ssl.TlsStrategy
private String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addCloseable
(Closeable closeable) Adds to the list ofCloseable
resources to be managed by the client.final H2AsyncClientBuilder
addExecInterceptorAfter
(String existing, String name, AsyncExecChainHandler interceptor) Adds this execution interceptor after interceptor with the given name.final H2AsyncClientBuilder
addExecInterceptorBefore
(String existing, String name, AsyncExecChainHandler interceptor) Adds this execution interceptor before an existing interceptor.final H2AsyncClientBuilder
addExecInterceptorFirst
(String name, AsyncExecChainHandler interceptor) Add an interceptor to the head of the processing list.final H2AsyncClientBuilder
addExecInterceptorLast
(String name, AsyncExecChainHandler interceptor) Add an interceptor to the tail of the processing list.final H2AsyncClientBuilder
addRequestInterceptorFirst
(org.apache.hc.core5.http.HttpRequestInterceptor interceptor) Adds this protocol interceptor to the head of the protocol processing list.final H2AsyncClientBuilder
addRequestInterceptorLast
(org.apache.hc.core5.http.HttpRequestInterceptor interceptor) Adds this protocol interceptor to the tail of the protocol processing list.final H2AsyncClientBuilder
addResponseInterceptorFirst
(org.apache.hc.core5.http.HttpResponseInterceptor interceptor) Adds this protocol interceptor to the head of the protocol processing list.final H2AsyncClientBuilder
addResponseInterceptorLast
(org.apache.hc.core5.http.HttpResponseInterceptor interceptor) Adds this protocol interceptor to the tail of the protocol processing list.build()
static H2AsyncClientBuilder
create()
protected void
customizeExecChain
(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition) Request exec chain customization and extension.final H2AsyncClientBuilder
Disables authentication scheme caching.final H2AsyncClientBuilder
Disables automatic request recovery and re-execution.final H2AsyncClientBuilder
Disables state (cookie) management.final H2AsyncClientBuilder
Disables automatic redirect handling.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.private static String
getProperty
(String key, String defaultValue) final H2AsyncClientBuilder
replaceExecInterceptor
(String existing, AsyncExecChainHandler interceptor) Replace an existing interceptor with the given name with new interceptor.final H2AsyncClientBuilder
setCharCodingConfig
(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig) SetsCharCodingConfig
configuration.final H2AsyncClientBuilder
setConnectionConfigResolver
(org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost, ConnectionConfig> connectionConfigResolver) AssignsResolver
forConnectionConfig
on a per host basis.final H2AsyncClientBuilder
setDefaultAuthSchemeRegistry
(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry) Assigns defaultAuthScheme
registry which will be used for request execution if not explicitly set in the client execution context.final H2AsyncClientBuilder
setDefaultConnectionConfig
(ConnectionConfig connectionConfig) Assigns the sameConnectionConfig
for all hosts.final H2AsyncClientBuilder
setDefaultCookieSpecRegistry
(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry) Assigns defaultCookieSpec
registry which will be used for request execution if not explicitly set in the client execution context.final H2AsyncClientBuilder
setDefaultCookieStore
(CookieStore cookieStore) Assigns defaultCookieStore
instance which will be used for request execution if not explicitly set in the client execution context.final H2AsyncClientBuilder
setDefaultCredentialsProvider
(CredentialsProvider credentialsProvider) Assigns defaultCredentialsProvider
instance which will be used for request execution if not explicitly set in the client execution context.final H2AsyncClientBuilder
setDefaultHeaders
(Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders) Assigns default request header values.final H2AsyncClientBuilder
setDefaultRequestConfig
(RequestConfig config) Assigns defaultRequestConfig
instance which will be used for request execution if not explicitly set in the client execution context.final H2AsyncClientBuilder
setDnsResolver
(DnsResolver dnsResolver) AssignsDnsResolver
instance.final H2AsyncClientBuilder
setH2Config
(org.apache.hc.core5.http2.config.H2Config h2Config) SetsH2Config
configuration.final H2AsyncClientBuilder
setIOReactorConfig
(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig) SetsIOReactorConfig
configuration.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.final H2AsyncClientBuilder
setIoSessionDecorator
(org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator) Sets theIOSession
Decorator
that will be use with the client's IOReactor.final H2AsyncClientBuilder
setIOSessionListener
(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener) SetsIOSessionListener
listener.final H2AsyncClientBuilder
setProxyAuthenticationStrategy
(AuthenticationStrategy proxyAuthStrategy) AssignsAuthenticationStrategy
instance for proxy authentication.setRedirectStrategy
(RedirectStrategy redirectStrategy) AssignsRedirectStrategy
instance.final H2AsyncClientBuilder
setRetryStrategy
(HttpRequestRetryStrategy retryStrategy) AssignsHttpRequestRetryStrategy
instance.final H2AsyncClientBuilder
setRoutePlanner
(HttpRoutePlanner routePlanner) AssignsHttpRoutePlanner
instance.final H2AsyncClientBuilder
setSchemePortResolver
(SchemePortResolver schemePortResolver) AssignsSchemePortResolver
instance.final H2AsyncClientBuilder
setTargetAuthenticationStrategy
(AuthenticationStrategy targetAuthStrategy) AssignsAuthenticationStrategy
instance for target host authentication.final H2AsyncClientBuilder
setThreadFactory
(ThreadFactory threadFactory) AssignsThreadFactory
instance.final H2AsyncClientBuilder
setTlsStrategy
(org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy) AssignsTlsStrategy
instance.final H2AsyncClientBuilder
setUserAgent
(String userAgent) AssignsUser-Agent
value.final H2AsyncClientBuilder
Use 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
-
-
Constructor Details
-
H2AsyncClientBuilder
protected H2AsyncClientBuilder()
-
-
Method Details
-
create
-
setH2Config
SetsH2Config
configuration. -
setIOReactorConfig
public final H2AsyncClientBuilder setIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig) SetsIOReactorConfig
configuration. -
setIOSessionListener
public final H2AsyncClientBuilder setIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener) SetsIOSessionListener
listener.- Since:
- 5.2
-
setCharCodingConfig
public final H2AsyncClientBuilder setCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig) SetsCharCodingConfig
configuration. -
setTargetAuthenticationStrategy
public final H2AsyncClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy) AssignsAuthenticationStrategy
instance for target host authentication. -
setProxyAuthenticationStrategy
public final H2AsyncClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy) AssignsAuthenticationStrategy
instance for proxy authentication. -
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.- Since:
- 5.2
-
setIoSessionDecorator
public final H2AsyncClientBuilder setIoSessionDecorator(org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator) Sets theIOSession
Decorator
that will be use with the client's IOReactor.- Since:
- 5.2
-
addResponseInterceptorFirst
public final H2AsyncClientBuilder addResponseInterceptorFirst(org.apache.hc.core5.http.HttpResponseInterceptor interceptor) Adds this protocol interceptor to the head of the protocol processing list. -
addResponseInterceptorLast
public final H2AsyncClientBuilder addResponseInterceptorLast(org.apache.hc.core5.http.HttpResponseInterceptor interceptor) Adds this protocol interceptor to the tail of the protocol processing list. -
addExecInterceptorBefore
public final H2AsyncClientBuilder addExecInterceptorBefore(String existing, String name, AsyncExecChainHandler interceptor) Adds this execution interceptor before an existing interceptor. -
addExecInterceptorAfter
public final H2AsyncClientBuilder addExecInterceptorAfter(String existing, String name, AsyncExecChainHandler interceptor) Adds this execution interceptor after interceptor with the given name. -
replaceExecInterceptor
public final H2AsyncClientBuilder replaceExecInterceptor(String existing, AsyncExecChainHandler interceptor) Replace an existing interceptor with the given name with new interceptor. -
addExecInterceptorFirst
public final H2AsyncClientBuilder addExecInterceptorFirst(String name, AsyncExecChainHandler interceptor) Add an interceptor to the head of the processing list. -
addExecInterceptorLast
public final H2AsyncClientBuilder addExecInterceptorLast(String name, AsyncExecChainHandler interceptor) Add an interceptor to the tail of the processing list. -
addRequestInterceptorFirst
public final H2AsyncClientBuilder addRequestInterceptorFirst(org.apache.hc.core5.http.HttpRequestInterceptor interceptor) Adds this protocol interceptor to the head of the protocol processing list. -
addRequestInterceptorLast
public final H2AsyncClientBuilder addRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor) Adds this protocol interceptor to the tail of the protocol processing list. -
setRetryStrategy
AssignsHttpRequestRetryStrategy
instance.Please note this value can be overridden by the
disableAutomaticRetries()
method. -
setRedirectStrategy
AssignsRedirectStrategy
instance.Please note this value can be overridden by the
disableRedirectHandling()
method. -
setSchemePortResolver
AssignsSchemePortResolver
instance. -
setDnsResolver
AssignsDnsResolver
instance. -
setTlsStrategy
public final H2AsyncClientBuilder setTlsStrategy(org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy) AssignsTlsStrategy
instance. -
setThreadFactory
AssignsThreadFactory
instance. -
setUserAgent
AssignsUser-Agent
value. -
setDefaultHeaders
public final H2AsyncClientBuilder setDefaultHeaders(Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders) Assigns default request header values. -
setRoutePlanner
AssignsHttpRoutePlanner
instance. -
setDefaultCredentialsProvider
public final H2AsyncClientBuilder setDefaultCredentialsProvider(CredentialsProvider credentialsProvider) Assigns defaultCredentialsProvider
instance which will be used for request execution if not explicitly set in the client execution context. -
setDefaultAuthSchemeRegistry
public final H2AsyncClientBuilder setDefaultAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry) Assigns defaultAuthScheme
registry which will be used for request execution if not explicitly set in the client execution context. -
setDefaultCookieSpecRegistry
public final H2AsyncClientBuilder setDefaultCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry) Assigns defaultCookieSpec
registry which will be used for request execution if not explicitly set in the client execution context. -
setDefaultCookieStore
Assigns defaultCookieStore
instance which will be used for request execution if not explicitly set in the client execution context. -
setDefaultRequestConfig
Assigns defaultRequestConfig
instance which will be used for request execution if not explicitly set in the client execution context. -
setConnectionConfigResolver
public final H2AsyncClientBuilder setConnectionConfigResolver(org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost, ConnectionConfig> connectionConfigResolver) AssignsResolver
forConnectionConfig
on a per host basis.- Since:
- 5.2
-
setDefaultConnectionConfig
Assigns the sameConnectionConfig
for all hosts.- Since:
- 5.2
-
useSystemProperties
Use system properties when creating and configuring default implementations. -
disableRedirectHandling
Disables automatic redirect handling. -
disableAutomaticRetries
Disables automatic request recovery and re-execution. -
disableCookieManagement
Disables state (cookie) management. -
disableAuthCaching
Disables authentication scheme caching. -
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.
-
customizeExecChain
@Internal protected void customizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition) Request exec chain customization and extension.For internal use.
-
addCloseable
Adds to the list ofCloseable
resources to be managed by the client.For internal use.
-
build
-
getProperty
-