org.apache.hc.client5.http.impl.async

## Class H2AsyncClientBuilder

- java.lang.Object
- - org.apache.hc.client5.http.impl.async.H2AsyncClientBuilder

- Direct Known Subclasses:
    CachingH2AsyncClientBuilder

      public class H2AsyncClientBuilder
      extends Object

  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

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `H2AsyncClientBuilder()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addCloseable(Closeable closeable)` Adds to the list of `Closeable` resources to be managed by the client.
    `H2AsyncClientBuilder` | `addExecInterceptorAfter(String existing, String name, AsyncExecChainHandler interceptor)` Adds this execution interceptor after interceptor with the given name.
    `H2AsyncClientBuilder` | `addExecInterceptorBefore(String existing, String name, AsyncExecChainHandler interceptor)` Adds this execution interceptor before an existing interceptor.
    `H2AsyncClientBuilder` | `addExecInterceptorFirst(String name, AsyncExecChainHandler interceptor)` Add an interceptor to the head of the processing list.
    `H2AsyncClientBuilder` | `addExecInterceptorLast(String name, AsyncExecChainHandler interceptor)` Add an interceptor to the tail of the processing list.
    `H2AsyncClientBuilder` | `addRequestInterceptorFirst(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)` Adds this protocol interceptor to the head of the protocol processing list.
    `H2AsyncClientBuilder` | `addRequestInterceptorLast(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)` Adds this protocol interceptor to the tail of the protocol processing list.
    `H2AsyncClientBuilder` | `addResponseInterceptorFirst(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)` Adds this protocol interceptor to the head of the protocol processing list.
    `H2AsyncClientBuilder` | `addResponseInterceptorLast(org.apache.hc.core5.http.HttpResponseInterceptor interceptor)` Adds this protocol interceptor to the tail of the protocol processing list.
    `CloseableHttpAsyncClient` | `build()`
    `static H2AsyncClientBuilder` | `create()`
    `protected void` | `customizeExecChain(org.apache.hc.core5.http.config.NamedElementChain<AsyncExecChainHandler> execChainDefinition)` Request exec chain customization and extension.
    `H2AsyncClientBuilder` | `disableAuthCaching()` Disables authentication scheme caching.
    `H2AsyncClientBuilder` | `disableAutomaticRetries()` Disables automatic request recovery and re-execution.
    `H2AsyncClientBuilder` | `disableCookieManagement()` Disables state (cookie) management.
    `H2AsyncClientBuilder` | `disableRedirectHandling()` Disables automatic redirect handling.
    `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.
    `H2AsyncClientBuilder` | `replaceExecInterceptor(String existing, AsyncExecChainHandler interceptor)` Replace an existing interceptor with the given name with new interceptor.
    `H2AsyncClientBuilder` | `setCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)` Sets `CharCodingConfig` configuration.
    `H2AsyncClientBuilder` | `setConnectionConfigResolver(org.apache.hc.core5.function.Resolver<org.apache.hc.core5.http.HttpHost,ConnectionConfig> connectionConfigResolver)` Sets `Resolver` for `ConnectionConfig` on a per host basis.
    `H2AsyncClientBuilder` | `setDefaultAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeRegistry)` Sets default `AuthScheme` registry which will be used for request execution if not explicitly set in the client execution context.
    `H2AsyncClientBuilder` | `setDefaultConnectionConfig(ConnectionConfig connectionConfig)` Sets the same `ConnectionConfig` for all hosts.
    `H2AsyncClientBuilder` | `setDefaultCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecRegistry)` Sets default `CookieSpec` registry which will be used for request execution if not explicitly set in the client execution context.
    `H2AsyncClientBuilder` | `setDefaultCookieStore(CookieStore cookieStore)` Sets default `CookieStore` instance which will be used for request execution if not explicitly set in the client execution context.
    `H2AsyncClientBuilder` | `setDefaultCredentialsProvider(CredentialsProvider credentialsProvider)` Sets default `CredentialsProvider` instance which will be used for request execution if not explicitly set in the client execution context.
    `H2AsyncClientBuilder` | `setDefaultHeaders(Collection<? extends org.apache.hc.core5.http.Header> defaultHeaders)` Sets default request header values.
    `H2AsyncClientBuilder` | `setDefaultRequestConfig(RequestConfig config)` Sets default `RequestConfig` instance which will be used for request execution if not explicitly set in the client execution context.
    `H2AsyncClientBuilder` | `setDnsResolver(DnsResolver dnsResolver)` Sets `DnsResolver` instance.
    `H2AsyncClientBuilder` | `setH2Config(org.apache.hc.core5.http2.config.H2Config h2Config)` Sets `H2Config` configuration.
    `H2AsyncClientBuilder` | `setIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig)` Sets `IOReactorConfig` configuration.
    `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.
    `H2AsyncClientBuilder` | `setIoSessionDecorator(org.apache.hc.core5.function.Decorator<org.apache.hc.core5.reactor.IOSession> ioSessionDecorator)` Sets the `IOSession` `Decorator` that will be use with the client's IOReactor.
    `H2AsyncClientBuilder` | `setIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener)` Sets `IOSessionListener` listener.
    `H2AsyncClientBuilder` | `setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)` Sets `AuthenticationStrategy` instance for proxy authentication.
    `H2AsyncClientBuilder` | `setRedirectStrategy(RedirectStrategy redirectStrategy)` Sets `RedirectStrategy` instance.
    `H2AsyncClientBuilder` | `setRetryStrategy(HttpRequestRetryStrategy retryStrategy)` Sets `HttpRequestRetryStrategy` instance.
    `H2AsyncClientBuilder` | `setRoutePlanner(HttpRoutePlanner routePlanner)` Sets `HttpRoutePlanner` instance.
    `H2AsyncClientBuilder` | `setSchemePortResolver(SchemePortResolver schemePortResolver)` Sets `SchemePortResolver` instance.
    `H2AsyncClientBuilder` | `setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)` Sets `AuthenticationStrategy` instance for target host authentication.
    `H2AsyncClientBuilder` | `setThreadFactory(ThreadFactory threadFactory)` Sets `ThreadFactory` instance.
    `H2AsyncClientBuilder` | `setTlsStrategy(org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy)` Sets `TlsStrategy` instance.
    `H2AsyncClientBuilder` | `setUserAgent(String userAgent)` Sets `User-Agent` value.
    `H2AsyncClientBuilder` | `useSystemProperties()` Use system properties when creating and configuring default implementations.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### H2AsyncClientBuilder

          protected H2AsyncClientBuilder()

  - ### Method Detail

    - #### create

          public static H2AsyncClientBuilder create()

    - #### setH2Config

          public final H2AsyncClientBuilder setH2Config(org.apache.hc.core5.http2.config.H2Config h2Config)

      Sets `H2Config` configuration.
      Returns:
        this instance.

    - #### setIOReactorConfig

          public final H2AsyncClientBuilder setIOReactorConfig(org.apache.hc.core5.reactor.IOReactorConfig ioReactorConfig)

      Sets `IOReactorConfig` configuration.
      Returns:
        this instance.

    - #### setIOSessionListener

          public final H2AsyncClientBuilder setIOSessionListener(org.apache.hc.core5.reactor.IOSessionListener ioSessionListener)

      Sets `IOSessionListener` listener.
      Returns:
        this instance.
      Since:
        5.2

    - #### setCharCodingConfig

          public final H2AsyncClientBuilder setCharCodingConfig(org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)

      Sets `CharCodingConfig` configuration.
      Returns:
        this instance.

    - #### setTargetAuthenticationStrategy

          public final H2AsyncClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy)

      Sets `AuthenticationStrategy` instance for target host authentication.
      Returns:
        this instance.

    - #### setProxyAuthenticationStrategy

          public final H2AsyncClientBuilder setProxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy)

      Sets `AuthenticationStrategy` instance 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 the `IOSession` `Decorator` that will be use with the client's IOReactor.
      Returns:
        this instance.
      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.
      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

          public final H2AsyncClientBuilder setRetryStrategy(HttpRequestRetryStrategy retryStrategy)

      Sets `HttpRequestRetryStrategy` instance.

      Please note this value can be overridden by the `disableAutomaticRetries()` method.

      Returns:
        this instance.

    - #### setRedirectStrategy

          public H2AsyncClientBuilder setRedirectStrategy(RedirectStrategy redirectStrategy)

      Sets `RedirectStrategy` instance.

      Please note this value can be overridden by the `disableRedirectHandling()` method.

      Returns:
        this instance.

    - #### setSchemePortResolver

          public final H2AsyncClientBuilder setSchemePortResolver(SchemePortResolver schemePortResolver)

      Sets `SchemePortResolver` instance.
      Returns:
        this instance.

    - #### setDnsResolver

          public final H2AsyncClientBuilder setDnsResolver(DnsResolver dnsResolver)

      Sets `DnsResolver` instance.
      Returns:
        this instance.

    - #### setTlsStrategy

          public final H2AsyncClientBuilder setTlsStrategy(org.apache.hc.core5.http.nio.ssl.TlsStrategy tlsStrategy)

      Sets `TlsStrategy` instance.
      Returns:
        this instance.

    - #### setThreadFactory

          public final H2AsyncClientBuilder setThreadFactory(ThreadFactory threadFactory)

      Sets `ThreadFactory` instance.
      Returns:
        this instance.

    - #### setUserAgent

          public final H2AsyncClientBuilder setUserAgent(String userAgent)

      Sets `User-Agent` value.
      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

          public final H2AsyncClientBuilder setRoutePlanner(HttpRoutePlanner routePlanner)

      Sets `HttpRoutePlanner` instance.
      Returns:
        this instance.

    - #### setDefaultCredentialsProvider

          public final H2AsyncClientBuilder setDefaultCredentialsProvider(CredentialsProvider credentialsProvider)

      Sets default `CredentialsProvider` instance 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 default `AuthScheme` registry 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 default `CookieSpec` registry which will be used for request execution if not explicitly set in the client execution context.
      Returns:
        this instance.

    - #### setDefaultCookieStore

          public final H2AsyncClientBuilder setDefaultCookieStore(CookieStore cookieStore)

      Sets default `CookieStore` instance which will be used for request execution if not explicitly set in the client execution context.
      Returns:
        this instance.

    - #### setDefaultRequestConfig

          public final H2AsyncClientBuilder setDefaultRequestConfig(RequestConfig config)

      Sets default `RequestConfig` instance 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)

      Sets `Resolver` for `ConnectionConfig` on a per host basis.
      Returns:
        this instance.
      Since:
        5.2

    - #### setDefaultConnectionConfig

          public final H2AsyncClientBuilder setDefaultConnectionConfig(ConnectionConfig connectionConfig)

      Sets the same `ConnectionConfig` for all hosts.
      Returns:
        this instance.
      Since:
        5.2

    - #### useSystemProperties

          public final H2AsyncClientBuilder useSystemProperties()

      Use system properties when creating and configuring default implementations.
      Returns:
        this instance.

    - #### disableRedirectHandling

          public final H2AsyncClientBuilder disableRedirectHandling()

      Disables automatic redirect handling.
      Returns:
        this instance.

    - #### disableAutomaticRetries

          public final H2AsyncClientBuilder disableAutomaticRetries()

      Disables automatic request recovery and re-execution.
      Returns:
        this instance.

    - #### disableCookieManagement

          public final H2AsyncClientBuilder disableCookieManagement()

      Disables state (cookie) management.
      Returns:
        this instance.

    - #### disableAuthCaching

          public final H2AsyncClientBuilder 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

          @Internal
          protected void addCloseable(Closeable closeable)

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

      For internal use.

    - #### build

          public CloseableHttpAsyncClient build()

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.