public static class AsyncHttpClientConfig.Builder extends Object
AsyncHttpClient
Constructor and Description |
---|
Builder() |
Builder(AsyncHttpClientConfig prototype)
Create a config builder with values taken from the given prototype configuration.
|
Modifier and Type | Method and Description |
---|---|
AsyncHttpClientConfig.Builder |
addIOExceptionFilter(IOExceptionFilter ioExceptionFilter)
Add an
IOExceptionFilter that will be invoked when an IOException
occurs during the download/upload operations. |
AsyncHttpClientConfig.Builder |
addRequestFilter(RequestFilter requestFilter)
Add an
RequestFilter that will be invoked before AsyncHttpClient.executeRequest(Request) |
AsyncHttpClientConfig.Builder |
addResponseFilter(ResponseFilter responseFilter)
Add an
ResponseFilter that will be invoked as soon as the response is
received, and before AsyncHandler.onStatusReceived(HttpResponseStatus) . |
AsyncHttpClientConfig |
build()
Build an
AsyncHttpClientConfig |
AsyncHttpClientConfig.Builder |
removeIOExceptionFilter(IOExceptionFilter ioExceptionFilter)
Remove an
IOExceptionFilter tthat will be invoked when an IOException
occurs during the download/upload operations. |
AsyncHttpClientConfig.Builder |
removeRequestFilter(RequestFilter requestFilter)
Remove an
RequestFilter that will be invoked before AsyncHttpClient.executeRequest(Request) |
AsyncHttpClientConfig.Builder |
removeResponseFilter(ResponseFilter responseFilter)
Remove an
ResponseFilter that will be invoked as soon as the response is
received, and before AsyncHandler.onStatusReceived(HttpResponseStatus) . |
AsyncHttpClientConfig.Builder |
setAcceptAnyCertificate(boolean acceptAnyCertificate) |
AsyncHttpClientConfig.Builder |
setAllowPoolingConnections(boolean allowPoolingConnections)
Set true if connection can be pooled by a
ChannelPool . |
AsyncHttpClientConfig.Builder |
setAllowPoolingSslConnections(boolean allowPoolingSslConnections)
Return true is if connections pooling is enabled.
|
AsyncHttpClientConfig.Builder |
setAsyncHttpClientProviderConfig(AsyncHttpProviderConfig<?,?> providerConfig)
Set the
AsyncHttpProviderConfig |
AsyncHttpClientConfig.Builder |
setCompressionEnforced(boolean compressionEnforced)
Enforce HTTP compression.
|
AsyncHttpClientConfig.Builder |
setConnectionTTL(int connectionTTL)
Set the maximum time in millisecond connection can be added to the pool for further reuse
|
AsyncHttpClientConfig.Builder |
setConnectTimeout(int connectTimeOut)
Set the maximum time in millisecond an
AsyncHttpClient can wait when connecting to a remote host |
AsyncHttpClientConfig.Builder |
setDisableUrlEncodingForBoundedRequests(boolean disableUrlEncodingForBoundedRequests)
Disable automatic url escaping
|
AsyncHttpClientConfig.Builder |
setEnabledCipherSuites(String[] enabledCipherSuites) |
AsyncHttpClientConfig.Builder |
setEnabledProtocols(String[] enabledProtocols) |
AsyncHttpClientConfig.Builder |
setExecutorService(ExecutorService applicationThreadPool)
Set the
ExecutorService an AsyncHttpClient use for handling
asynchronous response. |
AsyncHttpClientConfig.Builder |
setFollowRedirect(boolean followRedirect)
Set to true to enable HTTP redirect
|
AsyncHttpClientConfig.Builder |
setHostnameVerifier(HostnameVerifier hostnameVerifier)
Set the
HostnameVerifier |
AsyncHttpClientConfig.Builder |
setIOThreadMultiplier(int multiplier) |
AsyncHttpClientConfig.Builder |
setMaxConnections(int maxConnections)
Set the maximum number of connections an
AsyncHttpClient can handle. |
AsyncHttpClientConfig.Builder |
setMaxConnectionsPerHost(int maxConnectionsPerHost)
Set the maximum number of connections per (scheme, host, port) an
AsyncHttpClient can handle. |
AsyncHttpClientConfig.Builder |
setMaxRedirects(int maxRedirects)
Set the maximum number of HTTP redirect
|
AsyncHttpClientConfig.Builder |
setMaxRequestRetry(int maxRequestRetry)
Set the number of time a request will be retried when an
IOException occurs because of a Network exception. |
AsyncHttpClientConfig.Builder |
setPooledConnectionIdleTimeout(int pooledConnectionIdleTimeout)
Set the maximum time in millisecond an
AsyncHttpClient will keep connection
idle in pool. |
AsyncHttpClientConfig.Builder |
setProxyServer(ProxyServer proxyServer)
Set an instance of
ProxyServer used by an AsyncHttpClient |
AsyncHttpClientConfig.Builder |
setProxyServerSelector(ProxyServerSelector proxyServerSelector)
Set an instance of
ProxyServerSelector used by an AsyncHttpClient |
AsyncHttpClientConfig.Builder |
setReadTimeout(int readTimeout)
Set the maximum time in millisecond an
AsyncHttpClient can stay idle. |
AsyncHttpClientConfig.Builder |
setRealm(Realm realm)
Set the
Realm that will be used for all requests. |
AsyncHttpClientConfig.Builder |
setRequestTimeout(int requestTimeout)
Set the maximum time in millisecond an
AsyncHttpClient waits until the response is completed. |
AsyncHttpClientConfig.Builder |
setSSLContext(SSLContext sslContext)
Set the
SSLContext for secure connection. |
AsyncHttpClientConfig.Builder |
setSslSessionCacheSize(Integer sslSessionCacheSize) |
AsyncHttpClientConfig.Builder |
setSslSessionTimeout(Integer sslSessionTimeout) |
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 |
setUseProxySelector(boolean useProxySelector)
Sets whether AHC should use the default JDK ProxySelector to select a proxy server.
|
AsyncHttpClientConfig.Builder |
setUserAgent(String userAgent)
Set the USER_AGENT header value
|
AsyncHttpClientConfig.Builder |
setUseRelativeURIsWithConnectProxies(boolean useRelativeURIsWithConnectProxies)
Configures this AHC instance to use relative URIs instead of absolute ones when talking with a SSL proxy or WebSocket proxy.
|
AsyncHttpClientConfig.Builder |
setWebSocketTimeout(int webSocketTimeout)
Set the maximum time in millisecond an
WebSocket can stay idle. |
public Builder()
public Builder(AsyncHttpClientConfig prototype)
prototype
- the configuration to use as a prototype.public AsyncHttpClientConfig.Builder setMaxConnections(int maxConnections)
AsyncHttpClient
can handle.maxConnections
- the maximum number of connections an AsyncHttpClient
can handle.AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setMaxConnectionsPerHost(int maxConnectionsPerHost)
AsyncHttpClient
can handle.maxConnectionsPerHost
- the maximum number of connections per (scheme, host, port) an AsyncHttpClient
can handle.AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setConnectTimeout(int connectTimeOut)
AsyncHttpClient
can wait when connecting to a remote hostconnectTimeOut
- the maximum time in millisecond an AsyncHttpClient
can wait when connecting to a remote hostAsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setWebSocketTimeout(int webSocketTimeout)
WebSocket
can stay idle.webSocketTimeout
- the maximum time in millisecond an WebSocket
can stay idle.AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setReadTimeout(int readTimeout)
AsyncHttpClient
can stay idle.readTimeout
- the maximum time in millisecond an AsyncHttpClient
can stay idle.AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setPooledConnectionIdleTimeout(int pooledConnectionIdleTimeout)
AsyncHttpClient
will keep connection
idle in pool.idleConnectionInPoolTimeout
- the maximum time in millisecond an AsyncHttpClient
will keep connection
idle in pool.AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setRequestTimeout(int requestTimeout)
AsyncHttpClient
waits until the response is completed.requestTimeout
- the maximum time in millisecond an AsyncHttpClient
waits until the response is completed.AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setFollowRedirect(boolean followRedirect)
redirectEnabled
- true if enabled.AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setMaxRedirects(int maxRedirects)
maxRedirects
- the maximum number of HTTP redirectAsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setCompressionEnforced(boolean compressionEnforced)
compressionEnforced
- true if compression is enforcedAsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setUserAgent(String userAgent)
userAgent
- the USER_AGENT header valueAsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setAllowPoolingConnections(boolean allowPoolingConnections)
ChannelPool
. Default is true.allowPoolingConnections
- true if connection can be pooled by a ChannelPool
AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setExecutorService(ExecutorService applicationThreadPool)
ExecutorService
an AsyncHttpClient
use for handling
asynchronous response.applicationThreadPool
- the ExecutorService
an AsyncHttpClient
use for handling
asynchronous response.AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setProxyServerSelector(ProxyServerSelector proxyServerSelector)
ProxyServerSelector
used by an AsyncHttpClient
proxyServerSelector
- instance of ProxyServerSelector
AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setProxyServer(ProxyServer proxyServer)
ProxyServer
used by an AsyncHttpClient
proxyServer
- instance of ProxyServer
AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setSSLContext(SSLContext sslContext)
SSLContext
for secure connection.sslContext
- the SSLContext
for secure connectionAsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setAsyncHttpClientProviderConfig(AsyncHttpProviderConfig<?,?> providerConfig)
AsyncHttpProviderConfig
providerConfig
- the AsyncHttpProviderConfig
AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setRealm(Realm realm)
Realm
that will be used for all requests.realm
- the Realm
AsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder addRequestFilter(RequestFilter requestFilter)
RequestFilter
that will be invoked before AsyncHttpClient.executeRequest(Request)
requestFilter
- RequestFilter
public AsyncHttpClientConfig.Builder removeRequestFilter(RequestFilter requestFilter)
RequestFilter
that will be invoked before AsyncHttpClient.executeRequest(Request)
requestFilter
- RequestFilter
public AsyncHttpClientConfig.Builder addResponseFilter(ResponseFilter responseFilter)
ResponseFilter
that will be invoked as soon as the response is
received, and before AsyncHandler.onStatusReceived(HttpResponseStatus)
.responseFilter
- an ResponseFilter
public AsyncHttpClientConfig.Builder removeResponseFilter(ResponseFilter responseFilter)
ResponseFilter
that will be invoked as soon as the response is
received, and before AsyncHandler.onStatusReceived(HttpResponseStatus)
.responseFilter
- an ResponseFilter
public AsyncHttpClientConfig.Builder addIOExceptionFilter(IOExceptionFilter ioExceptionFilter)
IOExceptionFilter
that will be invoked when an IOException
occurs during the download/upload operations.ioExceptionFilter
- an ResponseFilter
public AsyncHttpClientConfig.Builder removeIOExceptionFilter(IOExceptionFilter ioExceptionFilter)
IOExceptionFilter
tthat will be invoked when an IOException
occurs during the download/upload operations.ioExceptionFilter
- an ResponseFilter
public AsyncHttpClientConfig.Builder setMaxRequestRetry(int maxRequestRetry)
IOException
occurs because of a Network exception.maxRequestRetry
- the number of time a request will be retriedpublic AsyncHttpClientConfig.Builder setAllowPoolingSslConnections(boolean allowPoolingSslConnections)
allowPoolingSslConnections
- true if enabledpublic AsyncHttpClientConfig.Builder setDisableUrlEncodingForBoundedRequests(boolean disableUrlEncodingForBoundedRequests)
disableUrlEncodingForBoundedRequests
- public AsyncHttpClientConfig.Builder setUseProxySelector(boolean useProxySelector)
true
but setProxyServer(ProxyServer)
was used to explicitly set a proxy server, the latter is preferred.
See http://docs.oracle.com/javase/7/docs/api/java/net/ProxySelector.htmlpublic AsyncHttpClientConfig.Builder setUseProxyProperties(boolean useProxyProperties)
setUseProxySelector(boolean)
in that AsyncHttpClient will use its own logic to handle the system properties,
potentially supporting other protocols that the the JDK ProxySelector doesn't.
If useProxyProperties is set to true
but setUseProxySelector(boolean)
was also set to true, the latter is preferred.
See http://download.oracle.com/javase/1.4.2/docs/guide/net/properties.htmlpublic AsyncHttpClientConfig.Builder setIOThreadMultiplier(int multiplier)
public AsyncHttpClientConfig.Builder setHostnameVerifier(HostnameVerifier hostnameVerifier)
HostnameVerifier
hostnameVerifier
- HostnameVerifier
public AsyncHttpClientConfig.Builder setStrict302Handling(boolean strict302Handling)
strict302Handling
- strict handlingpublic AsyncHttpClientConfig.Builder setUseRelativeURIsWithConnectProxies(boolean useRelativeURIsWithConnectProxies)
useRelativeURIsWithConnectProxies
- public AsyncHttpClientConfig.Builder setConnectionTTL(int connectionTTL)
connectionTTL
- the maximum time in millisecond connection can be added to the pool for further reuseAsyncHttpClientConfig.Builder
public AsyncHttpClientConfig.Builder setAcceptAnyCertificate(boolean acceptAnyCertificate)
public AsyncHttpClientConfig.Builder setEnabledProtocols(String[] enabledProtocols)
public AsyncHttpClientConfig.Builder setEnabledCipherSuites(String[] enabledCipherSuites)
public AsyncHttpClientConfig.Builder setSslSessionCacheSize(Integer sslSessionCacheSize)
public AsyncHttpClientConfig.Builder setSslSessionTimeout(Integer sslSessionTimeout)
public AsyncHttpClientConfig build()
AsyncHttpClientConfig
AsyncHttpClientConfig
Copyright © 2016. All Rights Reserved.