public static class

AsyncHttpClientConfig.Builder

extends Object
java.lang.Object
   ↳ com.ning.http.client.AsyncHttpClientConfig.Builder

Class Overview

Builder for an AsyncHttpClient

Summary

Public Constructors
AsyncHttpClientConfig.Builder()
AsyncHttpClientConfig.Builder(AsyncHttpClientConfig prototype)
Create a config builder with values taken from the given prototype configuration.
Public Methods
AsyncHttpClientConfig.Builder addIOExceptionFilter(IOExceptionFilter ioExceptionFilter)
Add an IOExceptionFilter that will be invoked when an java.io.IOException occurs during the download/upload operations.
AsyncHttpClientConfig.Builder addRequestFilter(RequestFilter requestFilter)
Add an RequestFilter that will be invoked before executeRequest(Request)
AsyncHttpClientConfig.Builder addResponseFilter(ResponseFilter responseFilter)
Add an ResponseFilter that will be invoked as soon as the response is received, and before onStatusReceived(HttpResponseStatus).
AsyncHttpClientConfig build()
int getRequestCompressionLevel()
Return the compression level, or -1 if no compression is used.
AsyncHttpClientConfig.Builder removeIOExceptionFilter(IOExceptionFilter ioExceptionFilter)
Remove an IOExceptionFilter tthat will be invoked when an java.io.IOException occurs during the download/upload operations.
AsyncHttpClientConfig.Builder removeRequestFilter(RequestFilter requestFilter)
Remove an RequestFilter that will be invoked before executeRequest(Request)
AsyncHttpClientConfig.Builder removeResponseFilter(ResponseFilter responseFilter)
Remove an ResponseFilter that will be invoked as soon as the response is received, and before onStatusReceived(HttpResponseStatus).
AsyncHttpClientConfig.Builder setAllowPoolingConnection(boolean allowPoolingConnection)
Set true if connection can be pooled by a ConnectionsPool.
AsyncHttpClientConfig.Builder setAllowSslConnectionPool(boolean allowSslConnectionPool)
Return true is if connections pooling is enabled.
AsyncHttpClientConfig.Builder setAsyncHttpClientProviderConfig(AsyncHttpProviderConfig<?, ?> providerConfig)
AsyncHttpClientConfig.Builder setCompressionEnabled(boolean compressionEnabled)
Enable HTTP compression.
AsyncHttpClientConfig.Builder setConnectionTimeoutInMs(int defaultConnectionTimeOutInMs)
Set the maximum time in millisecond an AsyncHttpClient can wait when connecting to a remote host
AsyncHttpClientConfig.Builder setConnectionsPool(ConnectionsPool<?, ?> connectionsPool)
AsyncHttpClientConfig.Builder setExecutorService(ExecutorService applicationThreadPool)
Set the java.util.concurrent.ExecutorService an AsyncHttpClient use for handling asynchronous response.
AsyncHttpClientConfig.Builder setFollowRedirects(boolean redirectEnabled)
Set to true to enable HTTP redirect
AsyncHttpClientConfig.Builder setHostnameVerifier(HostnameVerifier hostnameVerifier)
Set the HostnameVerifier
AsyncHttpClientConfig.Builder setIOThreadMultiplier(int multiplier)
AsyncHttpClientConfig.Builder setIdleConnectionInPoolTimeoutInMs(int defaultIdleConnectionInPoolTimeoutInMs)
Set the maximum time in millisecond an AsyncHttpClient will keep connection idle in pool.
AsyncHttpClientConfig.Builder setIdleConnectionTimeoutInMs(int defaultIdleConnectionTimeoutInMs)
Set the maximum time in millisecond an AsyncHttpClient can stay idle.
AsyncHttpClientConfig.Builder setKeepAlive(boolean allowPoolingConnection)
This method is deprecated. - Use setAllowPoolingConnection(boolean)
AsyncHttpClientConfig.Builder setMaxRequestRetry(int maxRequestRetry)
Set the number of time a request will be retried when an java.io.IOException occurs because of a Network exception.
AsyncHttpClientConfig.Builder setMaximumConnectionsPerHost(int defaultMaxConnectionPerHost)
Set the maximum number of connections per hosts an AsyncHttpClient can handle.
AsyncHttpClientConfig.Builder setMaximumConnectionsTotal(int defaultMaxTotalConnections)
Set the maximum number of connections an AsyncHttpClient can handle.
AsyncHttpClientConfig.Builder setMaximumNumberOfRedirects(int maxDefaultRedirects)
Set the maximum number of HTTP redirect
AsyncHttpClientConfig.Builder setProxyServer(ProxyServer proxyServer)
Set an instance of ProxyServer used by an AsyncHttpClient
AsyncHttpClientConfig.Builder setRealm(Realm realm)
Set the Realm that will be used for all requests.
AsyncHttpClientConfig.Builder setRemoveQueryParamsOnRedirect(boolean removeQueryParamOnRedirect)
Set to false if you don't want the query parameters removed when a redirect occurs.
AsyncHttpClientConfig.Builder setRequestCompressionLevel(int requestCompressionLevel)
Set the compression level, or -1 if no compression is used.
AsyncHttpClientConfig.Builder setRequestTimeoutInMs(int defaultRequestTimeoutInMs)
Set the maximum time in millisecond an AsyncHttpClient wait for a response
AsyncHttpClientConfig.Builder setSSLContext(SSLContext sslContext)
Set the SSLContext for secure connection.
AsyncHttpClientConfig.Builder setSSLEngineFactory(SSLEngineFactory sslEngineFactory)
Set the SSLEngineFactory for secure connection.
AsyncHttpClientConfig.Builder setScheduledExecutorService(ScheduledExecutorService reaper)
Set theScheduledExecutorService used to expire idle connections.
AsyncHttpClientConfig.Builder setStrict302Handling(boolean strict302Handling)
Configures this AHC instance to be strict in it's handling of 302 redirects in a POST/Redirect/GET situation.
AsyncHttpClientConfig.Builder setUseProxyProperties(boolean useProxyProperties)
Sets whether AHC should use the default http.proxy* system properties to obtain proxy information.
AsyncHttpClientConfig.Builder setUseRawUrl(boolean useRawUrl)
Allows use unescaped URLs in requests useful for retrieving data from broken sites
AsyncHttpClientConfig.Builder setUserAgent(String userAgent)
Set the USER_AGENT header value
AsyncHttpClientConfig.Builder setWebSocketIdleTimeoutInMs(int defaultWebSocketIdleTimeoutInMs)
Set the maximum time in millisecond an WebSocket can stay idle.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AsyncHttpClientConfig.Builder ()

public AsyncHttpClientConfig.Builder (AsyncHttpClientConfig prototype)

Create a config builder with values taken from the given prototype configuration.

Parameters
prototype the configuration to use as a prototype.

Public Methods

public AsyncHttpClientConfig.Builder addIOExceptionFilter (IOExceptionFilter ioExceptionFilter)

Add an IOExceptionFilter that will be invoked when an java.io.IOException occurs during the download/upload operations.

Parameters
ioExceptionFilter an ResponseFilter
Returns
  • this

public AsyncHttpClientConfig.Builder addRequestFilter (RequestFilter requestFilter)

Add an RequestFilter that will be invoked before executeRequest(Request)

Parameters
requestFilter RequestFilter
Returns
  • this

public AsyncHttpClientConfig.Builder addResponseFilter (ResponseFilter responseFilter)

Add an ResponseFilter that will be invoked as soon as the response is received, and before onStatusReceived(HttpResponseStatus).

Parameters
responseFilter an ResponseFilter
Returns
  • this

public int getRequestCompressionLevel ()

Return the compression level, or -1 if no compression is used.

Returns
  • the compression level, or -1 if no compression is use

public AsyncHttpClientConfig.Builder removeIOExceptionFilter (IOExceptionFilter ioExceptionFilter)

Remove an IOExceptionFilter tthat will be invoked when an java.io.IOException occurs during the download/upload operations.

Parameters
ioExceptionFilter an ResponseFilter
Returns
  • this

public AsyncHttpClientConfig.Builder removeRequestFilter (RequestFilter requestFilter)

Remove an RequestFilter that will be invoked before executeRequest(Request)

Parameters
requestFilter RequestFilter
Returns
  • this

public AsyncHttpClientConfig.Builder removeResponseFilter (ResponseFilter responseFilter)

Remove an ResponseFilter that will be invoked as soon as the response is received, and before onStatusReceived(HttpResponseStatus).

Parameters
responseFilter an ResponseFilter
Returns
  • this

public AsyncHttpClientConfig.Builder setAllowPoolingConnection (boolean allowPoolingConnection)

Set true if connection can be pooled by a ConnectionsPool. Default is true.

Parameters
allowPoolingConnection true if connection can be pooled by a ConnectionsPool

public AsyncHttpClientConfig.Builder setAllowSslConnectionPool (boolean allowSslConnectionPool)

Return true is if connections pooling is enabled.

Parameters
allowSslConnectionPool true if enabled
Returns
  • this

public AsyncHttpClientConfig.Builder setAsyncHttpClientProviderConfig (AsyncHttpProviderConfig<?, ?> providerConfig)

Parameters
providerConfig the AsyncHttpProviderConfig

public AsyncHttpClientConfig.Builder setCompressionEnabled (boolean compressionEnabled)

Enable HTTP compression.

Parameters
compressionEnabled true if compression is enabled

public AsyncHttpClientConfig.Builder setConnectionTimeoutInMs (int defaultConnectionTimeOutInMs)

Set the maximum time in millisecond an AsyncHttpClient can wait when connecting to a remote host

Parameters
defaultConnectionTimeOutInMs the maximum time in millisecond an AsyncHttpClient can wait when connecting to a remote host

public AsyncHttpClientConfig.Builder setConnectionsPool (ConnectionsPool<?, ?> connectionsPool)

Parameters
connectionsPool the ConnectionsPool

public AsyncHttpClientConfig.Builder setExecutorService (ExecutorService applicationThreadPool)

Set the java.util.concurrent.ExecutorService an AsyncHttpClient use for handling asynchronous response.

Parameters
applicationThreadPool the java.util.concurrent.ExecutorService an AsyncHttpClient use for handling asynchronous response.

public AsyncHttpClientConfig.Builder setFollowRedirects (boolean redirectEnabled)

Set to true to enable HTTP redirect

Parameters
redirectEnabled true if enabled.

public AsyncHttpClientConfig.Builder setHostnameVerifier (HostnameVerifier hostnameVerifier)

Set the HostnameVerifier

Parameters
hostnameVerifier HostnameVerifier
Returns
  • this

public AsyncHttpClientConfig.Builder setIOThreadMultiplier (int multiplier)

public AsyncHttpClientConfig.Builder setIdleConnectionInPoolTimeoutInMs (int defaultIdleConnectionInPoolTimeoutInMs)

Set the maximum time in millisecond an AsyncHttpClient will keep connection idle in pool.

Parameters
defaultIdleConnectionInPoolTimeoutInMs the maximum time in millisecond an AsyncHttpClient will keep connection idle in pool.

public AsyncHttpClientConfig.Builder setIdleConnectionTimeoutInMs (int defaultIdleConnectionTimeoutInMs)

Set the maximum time in millisecond an AsyncHttpClient can stay idle.

Parameters
defaultIdleConnectionTimeoutInMs the maximum time in millisecond an AsyncHttpClient can stay idle.

public AsyncHttpClientConfig.Builder setKeepAlive (boolean allowPoolingConnection)

This method is deprecated.
- Use setAllowPoolingConnection(boolean)

Set true if connection can be pooled by a ConnectionsPool. Default is true.

Parameters
allowPoolingConnection true if connection can be pooled by a ConnectionsPool

public AsyncHttpClientConfig.Builder setMaxRequestRetry (int maxRequestRetry)

Set the number of time a request will be retried when an java.io.IOException occurs because of a Network exception.

Parameters
maxRequestRetry the number of time a request will be retried
Returns
  • this

public AsyncHttpClientConfig.Builder setMaximumConnectionsPerHost (int defaultMaxConnectionPerHost)

Set the maximum number of connections per hosts an AsyncHttpClient can handle.

Parameters
defaultMaxConnectionPerHost the maximum number of connections per host an AsyncHttpClient can handle.

public AsyncHttpClientConfig.Builder setMaximumConnectionsTotal (int defaultMaxTotalConnections)

Set the maximum number of connections an AsyncHttpClient can handle.

Parameters
defaultMaxTotalConnections the maximum number of connections an AsyncHttpClient can handle.

public AsyncHttpClientConfig.Builder setMaximumNumberOfRedirects (int maxDefaultRedirects)

Set the maximum number of HTTP redirect

Parameters
maxDefaultRedirects the maximum number of HTTP redirect

public AsyncHttpClientConfig.Builder setProxyServer (ProxyServer proxyServer)

Set an instance of ProxyServer used by an AsyncHttpClient

Parameters
proxyServer instance of ProxyServer

public AsyncHttpClientConfig.Builder setRealm (Realm realm)

Set the Realm that will be used for all requests.

Parameters
realm the Realm

public AsyncHttpClientConfig.Builder setRemoveQueryParamsOnRedirect (boolean removeQueryParamOnRedirect)

Set to false if you don't want the query parameters removed when a redirect occurs.

Returns
  • this

public AsyncHttpClientConfig.Builder setRequestCompressionLevel (int requestCompressionLevel)

Set the compression level, or -1 if no compression is used.

Parameters
requestCompressionLevel compression level, or -1 if no compression is use
Returns
  • this

public AsyncHttpClientConfig.Builder setRequestTimeoutInMs (int defaultRequestTimeoutInMs)

Set the maximum time in millisecond an AsyncHttpClient wait for a response

Parameters
defaultRequestTimeoutInMs the maximum time in millisecond an AsyncHttpClient wait for a response

public AsyncHttpClientConfig.Builder setSSLContext (SSLContext sslContext)

Set the SSLContext for secure connection.

Parameters
sslContext the SSLContext for secure connection

public AsyncHttpClientConfig.Builder setSSLEngineFactory (SSLEngineFactory sslEngineFactory)

Set the SSLEngineFactory for secure connection.

Parameters
sslEngineFactory the SSLEngineFactory for secure connection

public AsyncHttpClientConfig.Builder setScheduledExecutorService (ScheduledExecutorService reaper)

Set theScheduledExecutorService used to expire idle connections.

Parameters
reaper theScheduledExecutorService used to expire idle connections.

public AsyncHttpClientConfig.Builder setStrict302Handling (boolean strict302Handling)

Configures this AHC instance to be strict in it's handling of 302 redirects in a POST/Redirect/GET situation.

Parameters
strict302Handling strict handling
Returns
  • this

public AsyncHttpClientConfig.Builder setUseProxyProperties (boolean useProxyProperties)

Sets whether AHC should use the default http.proxy* system properties to obtain proxy information.

If useProxyProperties is set to true but setProxyServer(ProxyServer) was used to explicitly set a proxy server, the latter is preferred.

See http://download.oracle.com/javase/1.4.2/docs/guide/net/properties.html

public AsyncHttpClientConfig.Builder setUseRawUrl (boolean useRawUrl)

Allows use unescaped URLs in requests useful for retrieving data from broken sites

Returns
  • this

public AsyncHttpClientConfig.Builder setUserAgent (String userAgent)

Set the USER_AGENT header value

Parameters
userAgent the USER_AGENT header value

public AsyncHttpClientConfig.Builder setWebSocketIdleTimeoutInMs (int defaultWebSocketIdleTimeoutInMs)

Set the maximum time in millisecond an WebSocket can stay idle.

Parameters
defaultWebSocketIdleTimeoutInMs the maximum time in millisecond an WebSocket can stay idle.