Package be.wegenenverkeer.rxhttpclient
Class Builder<T,U extends Builder<T,U>>
- java.lang.Object
-
- be.wegenenverkeer.rxhttpclient.Builder<T,U>
-
- Direct Known Subclasses:
RxJavaHttpClient.Builder
public abstract class Builder<T,U extends Builder<T,U>> extends java.lang.ObjectA Builder forRxHttpClientbuilders.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<RequestSigner>requestSigners
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description UaddRequestSigner(RequestSigner requestSigner)Tbuild()abstract TcreateClient(org.asynchttpclient.AsyncHttpClient innerClient, RestClientConfig rcConfig, ClientRequestLogFormatter logFmt, RequestSigner... signers)This is for internal use only.UlogFormParams(java.util.List<java.lang.String> formParameterNames)UlogHeaders(java.util.List<java.lang.String> headerNames)UsetAccept(java.lang.String acceptHeaderValue)Sets the default Accept request-header for requests built using this instance.UsetAcceptAnyCertificate(boolean acceptAnyCertificate)UsetAllowPoolingConnections(boolean allowPoolingConnections)Deprecated.Use setKeepAlive(boolean) insteadUsetAwsCredentialsProvider(AwsCredentialsProvider provider)UsetAwsEndPoint(AwsService service, AwsRegion region)UsetAwsEndPoint(AwsService service, AwsRegion region, java.lang.String domain)UsetBaseUrl(java.lang.String url)Sets the base URL for this client.UsetCompressionEnforced(boolean compressionEnforced)Enforce HTTP compression.UsetConnectionTTL(int connectionTTL)Set the maximum time in millisecond connection can be added to the pool for further reuseUsetConnectTimeout(int connectTimeOut)Set the maximum time in millisecond anAsyncHttpClientcan wait when connecting to a remote hostUsetDisableUrlEncodingForBoundedRequests(boolean disableUrlEncodingForBoundedRequests)Deprecated.Use setDisableUrlEncodingForBoundRequestsUsetDisableUrlEncodingForBoundRequests(boolean disableUrlEncodingForBoundedRequests)Disable automatic url escapingUsetEnabledCipherSuites(java.lang.String[] enabledCipherSuites)UsetEnabledProtocols(java.lang.String[] enabledProtocols)UsetFollowRedirect(boolean followRedirect)Set to true to enable HTTP redirectUsetKeepAlive(boolean keepAlive)Set true if connection can be pooled by a ChannelPool.UsetMaxConnections(int maxConnections)Set the maximum number of connections anAsyncHttpClientcan handle.UsetMaxRedirects(int maxRedirects)Set the maximum number of HTTP redirectUsetMaxRequestRetry(int maxRequestRetry)Set the number of time a request will be retried when anIOExceptionoccurs because of a Network exception.UsetPooledConnectionIdleTimeout(int pooledConnectionIdleTimeout)Set the maximum time in millisecond anAsyncHttpClientwill keep connection idle in pool.UsetReadTimeout(int readTimeout)Set the maximum time in millisecond anAsyncHttpClientcan stay idle.UsetRequestTimeout(int requestTimeout)Set the maximum time in millisecond anAsyncHttpClientwaits until the response is completed.UsetSslContext(io.netty.handler.ssl.SslContext sslContext)Set theSslContextfor secure connection.UsetStrict302Handling(boolean strict302Handling)Configures this AHC instance to be strict in it's handling of 302 redirects in a POST/Redirect/GET situation.UsetThreadFactory(java.util.concurrent.ThreadFactory threadFactory)Set theExecutorServiceanAsyncHttpClientuses for handling asynchronous response.UsetThrottling(int maxWait)Throttles requests by blocking until connections in the pool become available, waiting for the response to arrives before executing the next request.UsetUseInsecureTrustManager(boolean useInsecureTrustManager)UsetUseProxyProperties(boolean useProxyProperties)Sets whether AHC should use the default http.proxy* system properties to obtain proxy information.UsetUseProxySelector(boolean useProxySelector)Sets whether AHC should use the default JDK ProxySelector to select a proxy server.UsetUserAgent(java.lang.String userAgent)Set the USER_AGENT header value
-
-
-
Field Detail
-
requestSigners
protected java.util.List<RequestSigner> requestSigners
-
-
Method Detail
-
build
public T build()
-
createClient
public abstract T createClient(org.asynchttpclient.AsyncHttpClient innerClient, RestClientConfig rcConfig, ClientRequestLogFormatter logFmt, RequestSigner... signers)
This is for internal use only. Clients are advised NOT to use this methode.- Parameters:
innerClient-rcConfig-logFmt-signers-- Returns:
-
addRequestSigner
public U addRequestSigner(RequestSigner requestSigner)
-
setAccept
public U setAccept(java.lang.String acceptHeaderValue)
Sets the default Accept request-header for requests built using this instance.- Parameters:
acceptHeaderValue- the Media-range and accept-params to use as value for the Accept request-header field- Returns:
- (U)this Builder
- See Also:
- W3C HTTP 1.1 specs.
-
setBaseUrl
public U setBaseUrl(java.lang.String url)
Sets the base URL for this client.The base url will be prepended to any relative URL path specified in the
RequestBuilder- Parameters:
url- the base URL for this instance- Returns:
- (U)this.Builder
-
setMaxConnections
public U setMaxConnections(int maxConnections)
Set the maximum number of connections anAsyncHttpClientcan handle.- Parameters:
maxConnections- the maximum number of connections anAsyncHttpClientcan handle.- Returns:
- a
Builder
-
setAllowPoolingConnections
@Deprecated public U setAllowPoolingConnections(boolean allowPoolingConnections)
Deprecated.Use setKeepAlive(boolean) insteadSet true if connection can be pooled by a ChannelPool. Default is true.- Parameters:
allowPoolingConnections- true if connection can be pooled by a ChannelPool- Returns:
- a
Builder
-
setKeepAlive
public U setKeepAlive(boolean keepAlive)
Set true if connection can be pooled by a ChannelPool. Default is true.- Parameters:
keepAlive- true if connection can be pooled by a ChannelPool- Returns:
- a
Builder
-
setThrottling
public U setThrottling(int maxWait)
Throttles requests by blocking until connections in the pool become available, waiting for the response to arrives before executing the next request.- Parameters:
maxWait- timeout in millisceconds- Returns:
- (U)this Builder
-
setConnectTimeout
public U setConnectTimeout(int connectTimeOut)
Set the maximum time in millisecond anAsyncHttpClientcan wait when connecting to a remote host- Parameters:
connectTimeOut- the maximum time in millisecond anAsyncHttpClientcan wait when connecting to a remote host- Returns:
- a
Builder
-
setThreadFactory
public U setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
Set theExecutorServiceanAsyncHttpClientuses for handling asynchronous response.- Parameters:
threadFactory- thethreadFactoryanAsyncHttpClientuse for handling asynchronous response.- Returns:
- a
Builder
-
setMaxRequestRetry
public U setMaxRequestRetry(int maxRequestRetry)
Set the number of time a request will be retried when anIOExceptionoccurs because of a Network exception.- Parameters:
maxRequestRetry- the number of time a request will be retried- Returns:
- (U)this
-
setEnabledProtocols
public U setEnabledProtocols(java.lang.String[] enabledProtocols)
-
setEnabledCipherSuites
public U setEnabledCipherSuites(java.lang.String[] enabledCipherSuites)
-
setUseProxyProperties
public U setUseProxyProperties(boolean useProxyProperties)
Sets whether AHC should use the default http.proxy* system properties to obtain proxy information. This differs fromsetUseProxySelector(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
truebutsetUseProxySelector(boolean)was also set to true, the latter is preferred.See http://download.oracle.com/javase/1.4.2/docs/guide/net/properties.html
- Parameters:
useProxyProperties- whether AHC should use the default http.proxy* system properties
-
setUseProxySelector
public U setUseProxySelector(boolean useProxySelector)
Sets whether AHC should use the default JDK ProxySelector to select a proxy server.See http://docs.oracle.com/javase/7/docs/api/java/net/ProxySelector.html
- Parameters:
useProxySelector- whether AHC should use the default JDK ProxySelector to select a proxy server.
-
setMaxRedirects
public U setMaxRedirects(int maxRedirects)
Set the maximum number of HTTP redirect- Parameters:
maxRedirects- the maximum number of HTTP redirect- Returns:
- a
Builder
-
setAcceptAnyCertificate
public U setAcceptAnyCertificate(boolean acceptAnyCertificate)
-
setUseInsecureTrustManager
public U setUseInsecureTrustManager(boolean useInsecureTrustManager)
-
setStrict302Handling
public U 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:
- (U)this
- Since:
- 1.7.2
-
setConnectionTTL
public U setConnectionTTL(int connectionTTL)
Set the maximum time in millisecond connection can be added to the pool for further reuseDefault is -1 (no TTL set)
- Parameters:
connectionTTL- the maximum time in millisecond connection can be added to the pool for further reuse- Returns:
- a
Builder
-
setUserAgent
public U setUserAgent(java.lang.String userAgent)
Set the USER_AGENT header value- Parameters:
userAgent- the USER_AGENT header value- Returns:
- a
Builder
-
setFollowRedirect
public U setFollowRedirect(boolean followRedirect)
Set to true to enable HTTP redirect- Parameters:
followRedirect-- Returns:
- a
Builder
-
setDisableUrlEncodingForBoundedRequests
@Deprecated public U setDisableUrlEncodingForBoundedRequests(boolean disableUrlEncodingForBoundedRequests)
Deprecated.Use setDisableUrlEncodingForBoundRequestsDisable automatic url escaping- Parameters:
disableUrlEncodingForBoundedRequests- disables the url encoding if set to true- Returns:
- (U)this Builder
-
setDisableUrlEncodingForBoundRequests
public U setDisableUrlEncodingForBoundRequests(boolean disableUrlEncodingForBoundedRequests)
Disable automatic url escaping- Parameters:
disableUrlEncodingForBoundedRequests- disables the url encoding if set to true- Returns:
- (U)this Builder
-
setRequestTimeout
public U setRequestTimeout(int requestTimeout)
Set the maximum time in millisecond anAsyncHttpClientwaits until the response is completed.- Parameters:
requestTimeout- the maximum time in millisecond anAsyncHttpClientwaits until the response is completed.- Returns:
- a
Builder
-
setSslContext
public U setSslContext(io.netty.handler.ssl.SslContext sslContext)
Set theSslContextfor secure connection.- Parameters:
sslContext- the SSLContext for secure connection- Returns:
- a
Builder
-
setCompressionEnforced
public U setCompressionEnforced(boolean compressionEnforced)
Enforce HTTP compression.- Parameters:
compressionEnforced- true if compression is enforced- Returns:
- a
Builder
-
setPooledConnectionIdleTimeout
public U setPooledConnectionIdleTimeout(int pooledConnectionIdleTimeout)
Set the maximum time in millisecond anAsyncHttpClientwill keep connection idle in pool.Default is 60000 millis (1 min.)
- Parameters:
pooledConnectionIdleTimeout-- Returns:
- a
Builder
-
setReadTimeout
public U setReadTimeout(int readTimeout)
Set the maximum time in millisecond anAsyncHttpClientcan stay idle.- Parameters:
readTimeout- the maximum time in millisecond anRestClientcan stay idle.- Returns:
- a
Builder
-
setAwsEndPoint
public U setAwsEndPoint(AwsService service, AwsRegion region)
-
setAwsEndPoint
public U setAwsEndPoint(AwsService service, AwsRegion region, java.lang.String domain)
-
setAwsCredentialsProvider
public U setAwsCredentialsProvider(AwsCredentialsProvider provider)
-
logHeaders
public U logHeaders(java.util.List<java.lang.String> headerNames)
-
logFormParams
public U logFormParams(java.util.List<java.lang.String> formParameterNames)
-
-