Class H2AsyncClientBuilder
- java.lang.Object
-
- org.apache.hc.client5.http.impl.async.H2AsyncClientBuilder
-
- Direct Known Subclasses:
CachingH2AsyncClientBuilder
public class H2AsyncClientBuilder extends java.lang.ObjectBuilder for HTTP/2 onlyCloseableHttpAsyncClientinstances.Concurrent message exchanges with the same connection route executed with these
CloseableHttpAsyncClientinstances 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 Classes Modifier and Type Class Description private static classH2AsyncClientBuilder.ExecInterceptorEntry(package private) static classH2AsyncClientBuilder.IdleConnectionEvictorprivate static classH2AsyncClientBuilder.RequestInterceptorEntryprivate static classH2AsyncClientBuilder.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 org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost,ConnectionConfig>connectionConfigResolverprivate booleancookieManagementDisabledprivate org.apache.hc.core5.http.config.Lookup<CookieSpecFactory>cookieSpecRegistryprivate CookieStorecookieStoreprivate CredentialsProvidercredentialsProviderprivate java.util.Collection<? extends org.apache.hc.core5.http.Header>defaultHeadersprivate RequestConfigdefaultRequestConfigprivate DnsResolverdnsResolverprivate booleanevictIdleConnectionsprivate java.util.LinkedList<H2AsyncClientBuilder.ExecInterceptorEntry>execInterceptorsprivate 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 org.apache.hc.core5.util.TimeValuemaxIdleTimeprivate AuthenticationStrategyproxyAuthStrategyprivate booleanredirectHandlingDisabledprivate RedirectStrategyredirectStrategyprivate java.util.LinkedList<H2AsyncClientBuilder.RequestInterceptorEntry>requestInterceptorsprivate java.util.LinkedList<H2AsyncClientBuilder.ResponseInterceptorEntry>responseInterceptorsprivate HttpRequestRetryStrategyretryStrategyprivate HttpRoutePlannerroutePlannerprivate SchemePortResolverschemePortResolverprivate booleansystemPropertiesprivate AuthenticationStrategytargetAuthStrategyprivate java.util.concurrent.ThreadFactorythreadFactoryprivate org.apache.hc.core5.http.nio.ssl.TlsStrategytlsStrategyprivate java.lang.StringuserAgent
-
Constructor Summary
Constructors Modifier Constructor Description protectedH2AsyncClientBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCloseable(java.io.Closeable closeable)Adds to the list ofCloseableresources to be managed by the client.H2AsyncClientBuilderaddExecInterceptorAfter(java.lang.String existing, java.lang.String name, AsyncExecChainHandler interceptor)Adds this execution interceptor after interceptor with the given name.H2AsyncClientBuilderaddExecInterceptorBefore(java.lang.String existing, java.lang.String name, AsyncExecChainHandler interceptor)Adds this execution interceptor before an existing interceptor.H2AsyncClientBuilderaddExecInterceptorFirst(java.lang.String name, AsyncExecChainHandler interceptor)Add an interceptor to the head of the processing list.H2AsyncClientBuilderaddExecInterceptorLast(java.lang.String name, AsyncExecChainHandler interceptor)Add an interceptor to the tail of the processing list.H2AsyncClientBuilderaddRequestInterceptorFirst(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)Adds this protocol interceptor to the head of the protocol processing list.H2AsyncClientBuilderaddRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)Adds this protocol interceptor to the tail of the protocol processing list.H2AsyncClientBuilderaddResponseInterceptorFirst(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)Adds this protocol interceptor to the head of the protocol processing list.H2AsyncClientBuilderaddResponseInterceptorLast(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)Adds this protocol interceptor to the tail of the protocol processing list.CloseableHttpAsyncClientbuild()static H2AsyncClientBuildercreate()protected voidcustomizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition)Request exec chain customization and extension.H2AsyncClientBuilderdisableAuthCaching()Disables authentication scheme caching.H2AsyncClientBuilderdisableAutomaticRetries()Disables automatic request recovery and re-execution.H2AsyncClientBuilderdisableCookieManagement()Disables state (cookie) management.H2AsyncClientBuilderdisableRedirectHandling()Disables automatic redirect handling.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 java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)H2AsyncClientBuilderreplaceExecInterceptor(java.lang.String existing, AsyncExecChainHandler interceptor)Replace an existing interceptor with the given name with new interceptor.H2AsyncClientBuildersetCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)SetsCharCodingConfigconfiguration.H2AsyncClientBuildersetConnectionConfigResolver(org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost,ConnectionConfig> connectionConfigResolver)AssignsResolverforConnectionConfigon a per host basis.H2AsyncClientBuildersetDefaultAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry)Assigns defaultAuthSchemeregistry which will be used for request execution if not explicitly set in the client execution context.H2AsyncClientBuildersetDefaultConnectionConfig(ConnectionConfig connectionConfig)Assigns the sameConnectionConfigfor all hosts.H2AsyncClientBuildersetDefaultCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry)Assigns defaultCookieSpecregistry which will be used for request execution if not explicitly set in the client execution context.H2AsyncClientBuildersetDefaultCookieStore(CookieStore cookieStore)Assigns defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.H2AsyncClientBuildersetDefaultCredentialsProvider(CredentialsProvider credentialsProvider)Assigns defaultCredentialsProviderinstance which will be used for request execution if not explicitly set in the client execution context.H2AsyncClientBuildersetDefaultHeaders(java.util.Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders)Assigns default request header values.H2AsyncClientBuildersetDefaultRequestConfig(RequestConfig config)Assigns defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.H2AsyncClientBuildersetDnsResolver(DnsResolver dnsResolver)AssignsDnsResolverinstance.H2AsyncClientBuildersetH2Config(org.apache.hc.core5.http2.config.H2Config h2Config)SetsH2Configconfiguration.H2AsyncClientBuildersetIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig)SetsIOReactorConfigconfiguration.H2AsyncClientBuildersetIoReactorExceptionCallback(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.H2AsyncClientBuildersetIoSessionDecorator(org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator)Sets theIOSessionDecoratorthat will be use with the client's IOReactor.H2AsyncClientBuildersetIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener)SetsIOSessionListenerlistener.H2AsyncClientBuildersetProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)AssignsAuthenticationStrategyinstance for proxy authentication.H2AsyncClientBuildersetRedirectStrategy(RedirectStrategy redirectStrategy)AssignsRedirectStrategyinstance.H2AsyncClientBuildersetRetryStrategy(HttpRequestRetryStrategy retryStrategy)AssignsHttpRequestRetryStrategyinstance.H2AsyncClientBuildersetRoutePlanner(HttpRoutePlanner routePlanner)AssignsHttpRoutePlannerinstance.H2AsyncClientBuildersetSchemePortResolver(SchemePortResolver schemePortResolver)AssignsSchemePortResolverinstance.H2AsyncClientBuildersetTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)AssignsAuthenticationStrategyinstance for target host authentication.H2AsyncClientBuildersetThreadFactory(java.util.concurrent.ThreadFactory threadFactory)AssignsThreadFactoryinstance.H2AsyncClientBuildersetTlsStrategy(org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy)AssignsTlsStrategyinstance.H2AsyncClientBuildersetUserAgent(java.lang.String userAgent)AssignsUser-Agentvalue.H2AsyncClientBuilderuseSystemProperties()Use system properties when creating and configuring default implementations.
-
-
-
Field Detail
-
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
private SchemePortResolver schemePortResolver
-
targetAuthStrategy
private AuthenticationStrategy targetAuthStrategy
-
proxyAuthStrategy
private AuthenticationStrategy proxyAuthStrategy
-
requestInterceptors
private java.util.LinkedList<H2AsyncClientBuilder.RequestInterceptorEntry> requestInterceptors
-
responseInterceptors
private java.util.LinkedList<H2AsyncClientBuilder.ResponseInterceptorEntry> responseInterceptors
-
execInterceptors
private java.util.LinkedList<H2AsyncClientBuilder.ExecInterceptorEntry> execInterceptors
-
routePlanner
private HttpRoutePlanner routePlanner
-
redirectStrategy
private RedirectStrategy redirectStrategy
-
retryStrategy
private HttpRequestRetryStrategy retryStrategy
-
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
-
defaultHeaders
private java.util.Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders
-
defaultRequestConfig
private RequestConfig 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
private DnsResolver dnsResolver
-
tlsStrategy
private org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy
-
threadFactory
private java.util.concurrent.ThreadFactory threadFactory
-
closeables
private java.util.List<java.io.Closeable> closeables
-
ioReactorExceptionCallback
private org.apache.hc.core5.function.Callback<java.lang.Exception> ioReactorExceptionCallback
-
ioSessionDecorator
private org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator
-
-
Method Detail
-
create
public static H2AsyncClientBuilder create()
-
setH2Config
public final H2AsyncClientBuilder setH2Config(org.apache.hc.core5.http2.config.H2Config h2Config)
SetsH2Configconfiguration.
-
setIOReactorConfig
public final H2AsyncClientBuilder setIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig)
SetsIOReactorConfigconfiguration.
-
setIOSessionListener
public final H2AsyncClientBuilder setIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener)
SetsIOSessionListenerlistener.- Since:
- 5.2
-
setCharCodingConfig
public final H2AsyncClientBuilder setCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)
SetsCharCodingConfigconfiguration.
-
setTargetAuthenticationStrategy
public final H2AsyncClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)
AssignsAuthenticationStrategyinstance for target host authentication.
-
setProxyAuthenticationStrategy
public final H2AsyncClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)
AssignsAuthenticationStrategyinstance for proxy authentication.
-
setIoReactorExceptionCallback
public final H2AsyncClientBuilder 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.- 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.- 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(java.lang.String existing, java.lang.String name, AsyncExecChainHandler interceptor)
Adds this execution interceptor before an existing interceptor.
-
addExecInterceptorAfter
public final H2AsyncClientBuilder addExecInterceptorAfter(java.lang.String existing, java.lang.String name, AsyncExecChainHandler interceptor)
Adds this execution interceptor after interceptor with the given name.
-
replaceExecInterceptor
public final H2AsyncClientBuilder replaceExecInterceptor(java.lang.String existing, AsyncExecChainHandler interceptor)
Replace an existing interceptor with the given name with new interceptor.
-
addExecInterceptorFirst
public final H2AsyncClientBuilder addExecInterceptorFirst(java.lang.String name, AsyncExecChainHandler interceptor)
Add an interceptor to the head of the processing list.
-
addExecInterceptorLast
public final H2AsyncClientBuilder addExecInterceptorLast(java.lang.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
public final H2AsyncClientBuilder setRetryStrategy(HttpRequestRetryStrategy retryStrategy)
AssignsHttpRequestRetryStrategyinstance.Please note this value can be overridden by the
disableAutomaticRetries()method.
-
setRedirectStrategy
public H2AsyncClientBuilder setRedirectStrategy(RedirectStrategy redirectStrategy)
AssignsRedirectStrategyinstance.Please note this value can be overridden by the
disableRedirectHandling()method.
-
setSchemePortResolver
public final H2AsyncClientBuilder setSchemePortResolver(SchemePortResolver schemePortResolver)
AssignsSchemePortResolverinstance.
-
setDnsResolver
public final H2AsyncClientBuilder setDnsResolver(DnsResolver dnsResolver)
AssignsDnsResolverinstance.
-
setTlsStrategy
public final H2AsyncClientBuilder setTlsStrategy(org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy)
AssignsTlsStrategyinstance.
-
setThreadFactory
public final H2AsyncClientBuilder setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
AssignsThreadFactoryinstance.
-
setUserAgent
public final H2AsyncClientBuilder setUserAgent(java.lang.String userAgent)
AssignsUser-Agentvalue.
-
setDefaultHeaders
public final H2AsyncClientBuilder setDefaultHeaders(java.util.Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders)
Assigns default request header values.
-
setRoutePlanner
public final H2AsyncClientBuilder setRoutePlanner(HttpRoutePlanner routePlanner)
AssignsHttpRoutePlannerinstance.
-
setDefaultCredentialsProvider
public final H2AsyncClientBuilder setDefaultCredentialsProvider(CredentialsProvider credentialsProvider)
Assigns defaultCredentialsProviderinstance 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 defaultAuthSchemeregistry 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 defaultCookieSpecregistry which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultCookieStore
public final H2AsyncClientBuilder setDefaultCookieStore(CookieStore cookieStore)
Assigns defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultRequestConfig
public final H2AsyncClientBuilder setDefaultRequestConfig(RequestConfig config)
Assigns defaultRequestConfiginstance 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)
AssignsResolverforConnectionConfigon a per host basis.- Since:
- 5.2
-
setDefaultConnectionConfig
public final H2AsyncClientBuilder setDefaultConnectionConfig(ConnectionConfig connectionConfig)
Assigns the sameConnectionConfigfor all hosts.- Since:
- 5.2
-
useSystemProperties
public final H2AsyncClientBuilder useSystemProperties()
Use system properties when creating and configuring default implementations.
-
disableRedirectHandling
public final H2AsyncClientBuilder disableRedirectHandling()
Disables automatic redirect handling.
-
disableAutomaticRetries
public final H2AsyncClientBuilder disableAutomaticRetries()
Disables automatic request recovery and re-execution.
-
disableCookieManagement
public final H2AsyncClientBuilder disableCookieManagement()
Disables state (cookie) management.
-
disableAuthCaching
public final H2AsyncClientBuilder 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
@Internal protected void addCloseable(java.io.Closeable closeable)
Adds to the list ofCloseableresources to be managed by the client.For internal use.
-
build
public CloseableHttpAsyncClient build()
-
getProperty
private static java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
-
-