Class RequestConfig.Builder
- Enclosing class:
RequestConfig
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private org.apache.hc.core5.util.TimeValue
private org.apache.hc.core5.util.Timeout
private org.apache.hc.core5.util.Timeout
private boolean
private String
private boolean
private boolean
private int
private org.apache.hc.core5.http.HttpHost
private Collection
<String> private boolean
private org.apache.hc.core5.util.Timeout
private Collection
<String> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
setAuthenticationEnabled
(boolean authenticationEnabled) Determines whether authentication should be handled automatically.setCircularRedirectsAllowed
(boolean circularRedirectsAllowed) Determines whether circular redirects (redirects to the same location) should be allowed.setConnectionKeepAlive
(org.apache.hc.core5.util.TimeValue connectionKeepAlive) Determines the default of value of connection keep-alive time period when not explicitly communicated by the origin server with aKeep-Alive
response header.setConnectionRequestTimeout
(long connectionRequestTimeout, TimeUnit timeUnit) setConnectionRequestTimeout
(org.apache.hc.core5.util.Timeout connectionRequestTimeout) Returns the connection lease request timeout used when requesting a connection from the connection manager.setConnectTimeout
(long connectTimeout, TimeUnit timeUnit) Deprecated.setConnectTimeout
(org.apache.hc.core5.util.Timeout connectTimeout) Deprecated.setContentCompressionEnabled
(boolean contentCompressionEnabled) Determines whether the target server is requested to compress content.setCookieSpec
(String cookieSpec) Determines the name of the cookie specification to be used for HTTP state management.setDefaultKeepAlive
(long defaultKeepAlive, TimeUnit timeUnit) setExpectContinueEnabled
(boolean expectContinueEnabled) Determines whether the 'Expect: 100-Continue' handshake is enabled for entity enclosing methods.setHardCancellationEnabled
(boolean hardCancellationEnabled) Determines whether request cancellation, such as throughFuture#cancel(boolean)
, should kill the underlying connection.setMaxRedirects
(int maxRedirects) Returns the maximum number of redirects to be followed.setProxy
(org.apache.hc.core5.http.HttpHost proxy) Deprecated.UseDefaultProxyRoutePlanner
or a customHttpRoutePlanner
.setProxyPreferredAuthSchemes
(Collection<String> proxyPreferredAuthSchemes) Determines the order of preference for supported authentication schemes by their names when authenticating with the proxy host.setRedirectsEnabled
(boolean redirectsEnabled) Determines whether redirects should be handled automatically.setResponseTimeout
(long responseTimeout, TimeUnit timeUnit) setResponseTimeout
(org.apache.hc.core5.util.Timeout responseTimeout) Determines the timeout until arrival of a response from the opposite endpoint.setTargetPreferredAuthSchemes
(Collection<String> targetPreferredAuthSchemes) Determines the order of preference for supported authentication schemes by their names when authenticating with the target host.
-
Field Details
-
expectContinueEnabled
private boolean expectContinueEnabled -
proxy
private org.apache.hc.core5.http.HttpHost proxy -
cookieSpec
-
redirectsEnabled
private boolean redirectsEnabled -
circularRedirectsAllowed
private boolean circularRedirectsAllowed -
maxRedirects
private int maxRedirects -
authenticationEnabled
private boolean authenticationEnabled -
targetPreferredAuthSchemes
-
proxyPreferredAuthSchemes
-
connectionRequestTimeout
private org.apache.hc.core5.util.Timeout connectionRequestTimeout -
connectTimeout
private org.apache.hc.core5.util.Timeout connectTimeout -
responseTimeout
private org.apache.hc.core5.util.Timeout responseTimeout -
connectionKeepAlive
private org.apache.hc.core5.util.TimeValue connectionKeepAlive -
contentCompressionEnabled
private boolean contentCompressionEnabled -
hardCancellationEnabled
private boolean hardCancellationEnabled
-
-
Constructor Details
-
Builder
Builder()
-
-
Method Details
-
setExpectContinueEnabled
Determines whether the 'Expect: 100-Continue' handshake is enabled for entity enclosing methods. The purpose of the 'Expect: 100-Continue' handshake is to allow a client that is sending a request message with a request body to determine if the origin server is willing to accept the request (based on the request headers) before the client sends the request body.The use of the 'Expect: 100-continue' handshake can result in a noticeable performance improvement for entity enclosing requests (such as POST and PUT) that require the target server's authentication.
'Expect: 100-continue' handshake should be used with caution, as it may cause problems with HTTP servers and proxies that do not support HTTP/1.1 protocol.
Default:
false
-
setProxy
Deprecated.UseDefaultProxyRoutePlanner
or a customHttpRoutePlanner
.Returns HTTP proxy to be used for request execution.Default:
null
-
setCookieSpec
Determines the name of the cookie specification to be used for HTTP state management.Default:
null
-
setRedirectsEnabled
Determines whether redirects should be handled automatically.Default:
true
-
setCircularRedirectsAllowed
Determines whether circular redirects (redirects to the same location) should be allowed. The HTTP spec is not sufficiently clear whether circular redirects are permitted, therefore optionally they can be enabledDefault:
false
-
setMaxRedirects
Returns the maximum number of redirects to be followed. The limit on number of redirects is intended to prevent infinite loops.Default:
50
-
setAuthenticationEnabled
Determines whether authentication should be handled automatically.Default:
true
-
setTargetPreferredAuthSchemes
public RequestConfig.Builder setTargetPreferredAuthSchemes(Collection<String> targetPreferredAuthSchemes) Determines the order of preference for supported authentication schemes by their names when authenticating with the target host.Default:
null
-
setProxyPreferredAuthSchemes
public RequestConfig.Builder setProxyPreferredAuthSchemes(Collection<String> proxyPreferredAuthSchemes) Determines the order of preference for supported authentication schemes by their names when authenticating with the proxy host.Default:
null
-
setConnectionRequestTimeout
public RequestConfig.Builder setConnectionRequestTimeout(org.apache.hc.core5.util.Timeout connectionRequestTimeout) Returns the connection lease request timeout used when requesting a connection from the connection manager.Default: 3 minutes.
-
setConnectionRequestTimeout
public RequestConfig.Builder setConnectionRequestTimeout(long connectionRequestTimeout, TimeUnit timeUnit) - See Also:
-
setConnectTimeout
@Deprecated public RequestConfig.Builder setConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout) Deprecated.Determines the timeout until a new connection is fully established. This may also include transport security negotiation exchanges such asSSL
orTLS
protocol negotiation).A timeout value of zero is interpreted as an infinite timeout.
Default: 3 minutes
-
setConnectTimeout
Deprecated.- See Also:
-
setResponseTimeout
Determines the timeout until arrival of a response from the opposite endpoint.A timeout value of zero is interpreted as an infinite timeout.
Please note that response timeout may be unsupported by HTTP transports with message multiplexing.
Default:
null
- Since:
- 5.0
-
setResponseTimeout
- See Also:
-
setConnectionKeepAlive
public RequestConfig.Builder setConnectionKeepAlive(org.apache.hc.core5.util.TimeValue connectionKeepAlive) Determines the default of value of connection keep-alive time period when not explicitly communicated by the origin server with aKeep-Alive
response header.A negative value is interpreted as an infinite keep-alive period.
Default: 3 minutes
- Since:
- 5.0
-
setDefaultKeepAlive
- See Also:
-
setContentCompressionEnabled
Determines whether the target server is requested to compress content.Default:
true
- Since:
- 4.5
-
setHardCancellationEnabled
Determines whether request cancellation, such as throughFuture#cancel(boolean)
, should kill the underlying connection. If this option is set to false, the client will attempt to preserve the underlying connection by allowing the request to complete in the background, discarding the response.Note that when this option is
true
, cancelling a request may cause other requests to fail, if they are waiting to use the same connection.On HTTP/2, this option has no effect. Request cancellation will always result in the stream being cancelled with a
RST_STREAM
. This has no effect on connection reuse.On non-asynchronous clients, this option has no effect. Request cancellation, such as through
HttpUriRequestBase#cancel()
, will always kill the underlying connection.Default:
true
- Since:
- 5.0
-
build
-
ConnectionConfig.Builder.setConnectTimeout(long, TimeUnit)
.