org.apache.http.impl.nio.client
Class HttpAsyncClientBuilder

java.lang.Object
  extended by org.apache.http.impl.nio.client.HttpAsyncClientBuilder

public class HttpAsyncClientBuilder
extends Object

Builder for CloseableHttpAsyncClient instances.

When a particular component is not explicitly 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 calling build().

Please note that some settings used by this class can be mutually exclusive and may not apply when building CloseableHttpAsyncClient instances.

Since:
4.0

Constructor Summary
protected HttpAsyncClientBuilder()
           
 
Method Summary
 HttpAsyncClientBuilder addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
          Adds this protocol interceptor to the head of the protocol processing list.
 HttpAsyncClientBuilder addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)
          Adds this protocol interceptor to the head of the protocol processing list.
 HttpAsyncClientBuilder addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
          Adds this protocol interceptor to the tail of the protocol processing list.
 HttpAsyncClientBuilder addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
          Adds this protocol interceptor to the tail of the protocol processing list.
 CloseableHttpAsyncClient build()
           
static HttpAsyncClientBuilder create()
           
 HttpAsyncClientBuilder disableAuthCaching()
          Disables authentication scheme caching.
 HttpAsyncClientBuilder disableConnectionState()
          Disables connection state tracking.
 HttpAsyncClientBuilder disableCookieManagement()
          Disables state (cookie) management.
 HttpAsyncClientBuilder setConnectionManager(NHttpClientConnectionManager connManager)
          Assigns NHttpClientConnectionManager instance.
 HttpAsyncClientBuilder setConnectionManagerShared(boolean shared)
          Defines the connection manager is to be shared by multiple client instances.
 HttpAsyncClientBuilder setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
          Assigns ConnectionReuseStrategy instance.
 HttpAsyncClientBuilder setConnectionTimeToLive(long connTimeToLive, TimeUnit connTimeToLiveTimeUnit)
          Sets maximum time to live for persistent connections
 HttpAsyncClientBuilder setDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry)
          Assigns default AuthScheme registry which will be used for request execution if not explicitly set in the client execution context.
 HttpAsyncClientBuilder setDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)
          Assigns default ConnectionConfig.
 HttpAsyncClientBuilder setDefaultCookieSpecRegistry(org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry)
          Assigns default CookieSpec registry which will be used for request execution if not explicitly set in the client execution context.
 HttpAsyncClientBuilder setDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)
          Assigns default CookieStore instance which will be used for request execution if not explicitly set in the client execution context.
 HttpAsyncClientBuilder setDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
          Assigns default CredentialsProvider instance which will be used for request execution if not explicitly set in the client execution context.
 HttpAsyncClientBuilder setDefaultHeaders(Collection<? extends org.apache.http.Header> defaultHeaders)
          Assigns default request header values.
 HttpAsyncClientBuilder setDefaultIOReactorConfig(org.apache.http.impl.nio.reactor.IOReactorConfig config)
          Assigns default IOReactorConfig.
 HttpAsyncClientBuilder setDefaultRequestConfig(org.apache.http.client.config.RequestConfig config)
          Assigns default RequestConfig instance which will be used for request execution if not explicitly set in the client execution context.
 HttpAsyncClientBuilder setEventHandler(org.apache.http.nio.NHttpClientEventHandler eventHandler)
          Assigns NHttpClientEventHandler instance.
 HttpAsyncClientBuilder setHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)
          Deprecated. (4.1) use setSSLHostnameVerifier(javax.net.ssl.HostnameVerifier)
 HttpAsyncClientBuilder setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
          Assigns HttpProcessor instance.
 HttpAsyncClientBuilder setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
          Assigns ConnectionKeepAliveStrategy instance.
 HttpAsyncClientBuilder setMaxConnPerRoute(int maxConnPerRoute)
          Assigns maximum connection per route value.
 HttpAsyncClientBuilder setMaxConnTotal(int maxConnTotal)
          Assigns maximum total connection value.
 HttpAsyncClientBuilder setProxy(org.apache.http.HttpHost proxy)
          Assigns default proxy value.
 HttpAsyncClientBuilder setProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy proxyAuthStrategy)
          Assigns AuthenticationStrategy instance for target host authentication.
 HttpAsyncClientBuilder setPublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher)
          Assigns file containing public suffix matcher.
 HttpAsyncClientBuilder setRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)
          Assigns RedirectStrategy instance.
 HttpAsyncClientBuilder setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
          Assigns HttpRoutePlanner instance.
 HttpAsyncClientBuilder setSchemePortResolver(org.apache.http.conn.SchemePortResolver schemePortResolver)
          Assigns SchemePortResolver instance.
 HttpAsyncClientBuilder setSSLContext(SSLContext sslcontext)
          Assigns SSLContext instance.
 HttpAsyncClientBuilder setSSLHostnameVerifier(HostnameVerifier hostnameVerifier)
          Assigns HostnameVerifier instance.
 HttpAsyncClientBuilder setSSLStrategy(SchemeIOSessionStrategy strategy)
          Assigns SchemeIOSessionStrategy instance.
 HttpAsyncClientBuilder setTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy targetAuthStrategy)
          Assigns AuthenticationStrategy instance for proxy authentication.
 HttpAsyncClientBuilder setThreadFactory(ThreadFactory threadFactory)
          Assigns ThreadFactory instance.
 HttpAsyncClientBuilder setUserAgent(String userAgent)
          Assigns User-Agent value.
 HttpAsyncClientBuilder setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
          Assigns UserTokenHandler instance.
 HttpAsyncClientBuilder 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

HttpAsyncClientBuilder

protected HttpAsyncClientBuilder()
Method Detail

create

public static HttpAsyncClientBuilder create()

setPublicSuffixMatcher

public final HttpAsyncClientBuilder setPublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher)
Assigns file containing public suffix matcher. Instances of this class can be created with PublicSuffixMatcherLoader.

Since:
4.1
See Also:
PublicSuffixMatcher, PublicSuffixMatcherLoader

setConnectionManager

public final HttpAsyncClientBuilder setConnectionManager(NHttpClientConnectionManager connManager)
Assigns NHttpClientConnectionManager 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.
Since:
4.1

setSchemePortResolver

public final HttpAsyncClientBuilder setSchemePortResolver(org.apache.http.conn.SchemePortResolver schemePortResolver)
Assigns SchemePortResolver instance.


setMaxConnTotal

public final HttpAsyncClientBuilder setMaxConnTotal(int maxConnTotal)
Assigns maximum total connection value.

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) method.


setMaxConnPerRoute

public final HttpAsyncClientBuilder setMaxConnPerRoute(int maxConnPerRoute)
Assigns maximum connection per route value.

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) method.


setConnectionTimeToLive

public final HttpAsyncClientBuilder setConnectionTimeToLive(long connTimeToLive,
                                                            TimeUnit connTimeToLiveTimeUnit)
Sets maximum time to live for persistent connections

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) method.

Since:
4.1

setConnectionReuseStrategy

public final HttpAsyncClientBuilder setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
Assigns ConnectionReuseStrategy instance.


setKeepAliveStrategy

public final HttpAsyncClientBuilder setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
Assigns ConnectionKeepAliveStrategy instance.


setUserTokenHandler

public final HttpAsyncClientBuilder setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
Assigns UserTokenHandler instance.

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


setTargetAuthenticationStrategy

public final HttpAsyncClientBuilder setTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy targetAuthStrategy)
Assigns AuthenticationStrategy instance for proxy authentication.


setProxyAuthenticationStrategy

public final HttpAsyncClientBuilder setProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy proxyAuthStrategy)
Assigns AuthenticationStrategy instance for target host authentication.


setHttpProcessor

public final HttpAsyncClientBuilder setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
Assigns HttpProcessor instance.


addInterceptorFirst

public final HttpAsyncClientBuilder addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.

Please note this value can be overridden by the setHttpProcessor( org.apache.http.protocol.HttpProcessor) method.


addInterceptorLast

public final HttpAsyncClientBuilder addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.

Please note this value can be overridden by the setHttpProcessor( org.apache.http.protocol.HttpProcessor) method.


addInterceptorFirst

public final HttpAsyncClientBuilder addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.

Please note this value can be overridden by the setHttpProcessor( org.apache.http.protocol.HttpProcessor) method.


addInterceptorLast

public final HttpAsyncClientBuilder addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.

Please note this value can be overridden by the setHttpProcessor( org.apache.http.protocol.HttpProcessor) method.


setRoutePlanner

public final HttpAsyncClientBuilder setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
Assigns HttpRoutePlanner instance.


setRedirectStrategy

public final HttpAsyncClientBuilder setRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)
Assigns RedirectStrategy instance.


setDefaultCookieStore

public final HttpAsyncClientBuilder setDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)
Assigns default CookieStore instance which will be used for request execution if not explicitly set in the client execution context.


setDefaultCredentialsProvider

public final HttpAsyncClientBuilder setDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
Assigns default CredentialsProvider instance which will be used for request execution if not explicitly set in the client execution context.


setDefaultAuthSchemeRegistry

public final HttpAsyncClientBuilder setDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry)
Assigns default AuthScheme registry which will be used for request execution if not explicitly set in the client execution context.


setDefaultCookieSpecRegistry

public final HttpAsyncClientBuilder setDefaultCookieSpecRegistry(org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry)
Assigns default CookieSpec registry which will be used for request execution if not explicitly set in the client execution context.


setUserAgent

public final HttpAsyncClientBuilder setUserAgent(String userAgent)
Assigns User-Agent value.

Please note this value can be overridden by the setHttpProcessor( org.apache.http.protocol.HttpProcessor) method.


setProxy

public final HttpAsyncClientBuilder setProxy(org.apache.http.HttpHost proxy)
Assigns default proxy value.

Please note this value can be overridden by the setRoutePlanner( org.apache.http.conn.routing.HttpRoutePlanner) method.


setSSLStrategy

public final HttpAsyncClientBuilder setSSLStrategy(SchemeIOSessionStrategy strategy)
Assigns SchemeIOSessionStrategy instance.

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) method.


setSSLContext

public final HttpAsyncClientBuilder setSSLContext(SSLContext sslcontext)
Assigns SSLContext instance.

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) and the setSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy) methods.


setHostnameVerifier

@Deprecated
public final HttpAsyncClientBuilder setHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)
Deprecated. (4.1) use setSSLHostnameVerifier(javax.net.ssl.HostnameVerifier)

Assigns X509HostnameVerifier instance.

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) and the setSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy) methods.


setSSLHostnameVerifier

public final HttpAsyncClientBuilder setSSLHostnameVerifier(HostnameVerifier hostnameVerifier)
Assigns HostnameVerifier instance.

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) and the setSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy) methods.

Since:
4.1

setDefaultHeaders

public final HttpAsyncClientBuilder setDefaultHeaders(Collection<? extends org.apache.http.Header> defaultHeaders)
Assigns default request header values.

Please note this value can be overridden by the setHttpProcessor( org.apache.http.protocol.HttpProcessor) method.


setDefaultIOReactorConfig

public final HttpAsyncClientBuilder setDefaultIOReactorConfig(org.apache.http.impl.nio.reactor.IOReactorConfig config)
Assigns default IOReactorConfig.

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) method.


setDefaultConnectionConfig

public final HttpAsyncClientBuilder setDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)
Assigns default ConnectionConfig.

Please note this value can be overridden by the setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager) method.


setDefaultRequestConfig

public final HttpAsyncClientBuilder setDefaultRequestConfig(org.apache.http.client.config.RequestConfig config)
Assigns default RequestConfig instance which will be used for request execution if not explicitly set in the client execution context.


setThreadFactory

public final HttpAsyncClientBuilder setThreadFactory(ThreadFactory threadFactory)
Assigns ThreadFactory instance.


setEventHandler

public final HttpAsyncClientBuilder setEventHandler(org.apache.http.nio.NHttpClientEventHandler eventHandler)
Assigns NHttpClientEventHandler instance.

Since:
4.1

disableConnectionState

public final HttpAsyncClientBuilder disableConnectionState()
Disables connection state tracking.


disableCookieManagement

public final HttpAsyncClientBuilder disableCookieManagement()
Disables state (cookie) management.

Please note this value can be overridden by the setHttpProcessor( org.apache.http.protocol.HttpProcessor) method.


disableAuthCaching

public final HttpAsyncClientBuilder disableAuthCaching()
Disables authentication scheme caching.

Please note this value can be overridden by the setHttpProcessor( org.apache.http.protocol.HttpProcessor) method.


useSystemProperties

public final HttpAsyncClientBuilder useSystemProperties()
Use system properties when creating and configuring default implementations.


build

public CloseableHttpAsyncClient build()


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