public static class RequestConfig.Builder extends Object
Modifier and Type | Method and Description |
---|---|
RequestConfig |
build() |
RequestConfig.Builder |
setAuthenticationEnabled(boolean authenticationEnabled)
Determines whether authentication should be handled automatically.
|
RequestConfig.Builder |
setCircularRedirectsAllowed(boolean circularRedirectsAllowed)
Determines whether circular redirects (redirects to the same location) should
be allowed.
|
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 a
Keep-Alive response
header. |
RequestConfig.Builder |
setConnectionRequestTimeout(long connectionRequestTimeout,
TimeUnit timeUnit) |
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.
|
RequestConfig.Builder |
setConnectTimeout(long connectTimeout,
TimeUnit timeUnit)
Deprecated.
|
RequestConfig.Builder |
setConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout)
Deprecated.
|
RequestConfig.Builder |
setContentCompressionEnabled(boolean contentCompressionEnabled)
Determines whether the target server is requested to compress content.
|
RequestConfig.Builder |
setCookieSpec(String cookieSpec)
Determines the name of the cookie specification to be used for HTTP state
management.
|
RequestConfig.Builder |
setDefaultKeepAlive(long defaultKeepAlive,
TimeUnit timeUnit) |
RequestConfig.Builder |
setExpectContinueEnabled(boolean expectContinueEnabled)
Determines whether the 'Expect: 100-Continue' handshake is enabled
for entity enclosing methods.
|
RequestConfig.Builder |
setHardCancellationEnabled(boolean hardCancellationEnabled)
Determines whether request cancellation, such as through
Future#cancel(boolean) , should kill the underlying connection. |
RequestConfig.Builder |
setMaxRedirects(int maxRedirects)
Returns the maximum number of redirects to be followed.
|
RequestConfig.Builder |
setProxy(org.apache.hc.core5.http.HttpHost proxy)
Deprecated.
Use
DefaultProxyRoutePlanner
or a custom HttpRoutePlanner . |
RequestConfig.Builder |
setProxyPreferredAuthSchemes(Collection<String> proxyPreferredAuthSchemes)
Determines the order of preference for supported authentication schemes
by their names when authenticating with the proxy host.
|
RequestConfig.Builder |
setRedirectsEnabled(boolean redirectsEnabled)
Determines whether redirects should be handled automatically.
|
RequestConfig.Builder |
setResponseTimeout(long responseTimeout,
TimeUnit timeUnit) |
RequestConfig.Builder |
setResponseTimeout(org.apache.hc.core5.util.Timeout responseTimeout)
Determines the timeout until arrival of a response from the opposite
endpoint.
|
RequestConfig.Builder |
setTargetPreferredAuthSchemes(Collection<String> targetPreferredAuthSchemes)
Determines the order of preference for supported authentication schemes
by their names when authenticating with the target host.
|
public RequestConfig.Builder setExpectContinueEnabled(boolean expectContinueEnabled)
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
@Deprecated public RequestConfig.Builder setProxy(org.apache.hc.core5.http.HttpHost proxy)
DefaultProxyRoutePlanner
or a custom HttpRoutePlanner
.
Default: null
public RequestConfig.Builder setCookieSpec(String cookieSpec)
Default: null
public RequestConfig.Builder setRedirectsEnabled(boolean redirectsEnabled)
Default: true
public RequestConfig.Builder setCircularRedirectsAllowed(boolean circularRedirectsAllowed)
Default: false
public RequestConfig.Builder setMaxRedirects(int maxRedirects)
Default: 50
public RequestConfig.Builder setAuthenticationEnabled(boolean authenticationEnabled)
Default: true
public RequestConfig.Builder setTargetPreferredAuthSchemes(Collection<String> targetPreferredAuthSchemes)
Default: null
public RequestConfig.Builder setProxyPreferredAuthSchemes(Collection<String> proxyPreferredAuthSchemes)
Default: null
public RequestConfig.Builder setConnectionRequestTimeout(org.apache.hc.core5.util.Timeout connectionRequestTimeout)
Default: 3 minutes.
public RequestConfig.Builder setConnectionRequestTimeout(long connectionRequestTimeout, TimeUnit timeUnit)
setConnectionRequestTimeout(Timeout)
@Deprecated public RequestConfig.Builder setConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout)
ConnectionConfig.Builder.setConnectTimeout(Timeout)
.SSL
or TLS
protocol negotiation).
A timeout value of zero is interpreted as an infinite timeout.
Default: 3 minutes
@Deprecated public RequestConfig.Builder setConnectTimeout(long connectTimeout, TimeUnit timeUnit)
ConnectionConfig.Builder.setConnectTimeout(long, TimeUnit)
.setConnectTimeout(Timeout)
public RequestConfig.Builder setResponseTimeout(org.apache.hc.core5.util.Timeout responseTimeout)
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
public RequestConfig.Builder setResponseTimeout(long responseTimeout, TimeUnit timeUnit)
setResponseTimeout(Timeout)
public RequestConfig.Builder setConnectionKeepAlive(org.apache.hc.core5.util.TimeValue connectionKeepAlive)
Keep-Alive
response
header.
A negative value is interpreted as an infinite keep-alive period.
Default: 3 minutes
public RequestConfig.Builder setDefaultKeepAlive(long defaultKeepAlive, TimeUnit timeUnit)
setConnectionKeepAlive(TimeValue)
public RequestConfig.Builder setContentCompressionEnabled(boolean contentCompressionEnabled)
Default: true
public RequestConfig.Builder setHardCancellationEnabled(boolean hardCancellationEnabled)
Future#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
public RequestConfig build()
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.