Class RequestConfig.Builder
- java.lang.Object
-
- org.apache.hc.client5.http.config.RequestConfig.Builder
-
- Enclosing class:
- RequestConfig
public static class RequestConfig.Builder extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private booleanauthenticationEnabledprivate booleancircularRedirectsAllowedprivate org.apache.hc.core5.util.TimeValueconnectionKeepAliveprivate org.apache.hc.core5.util.TimeoutconnectionRequestTimeoutprivate org.apache.hc.core5.util.TimeoutconnectTimeoutprivate booleancontentCompressionEnabledprivate java.lang.StringcookieSpecprivate booleanexpectContinueEnabledprivate org.apache.hc.core5.http2.priority.PriorityValueh2Priorityprivate booleanhardCancellationEnabledprivate intmaxRedirectsprivate booleanprotocolUpgradeEnabledprivate org.apache.hc.core5.http.HttpHostproxyprivate java.util.Collection<java.lang.String>proxyPreferredAuthSchemesprivate booleanredirectsEnabledprivate org.apache.hc.core5.util.TimeoutresponseTimeoutprivate java.util.Collection<java.lang.String>targetPreferredAuthSchemesprivate java.nio.file.PathunixDomainSocket
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RequestConfigbuild()RequestConfig.BuildersetAuthenticationEnabled(boolean authenticationEnabled)Determines whether authentication should be handled automatically.RequestConfig.BuildersetCircularRedirectsAllowed(boolean circularRedirectsAllowed)Determines whether circular redirects (redirects to the same location) should be allowed.RequestConfig.BuildersetConnectionKeepAlive(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-Aliveresponse header.RequestConfig.BuildersetConnectionRequestTimeout(long connectionRequestTimeout, java.util.concurrent.TimeUnit timeUnit)RequestConfig.BuildersetConnectionRequestTimeout(org.apache.hc.core5.util.Timeout connectionRequestTimeout)Returns the connection lease request timeout used when requesting a connection from the connection manager.RequestConfig.BuildersetConnectTimeout(long connectTimeout, java.util.concurrent.TimeUnit timeUnit)Deprecated.RequestConfig.BuildersetConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout)Deprecated.RequestConfig.BuildersetContentCompressionEnabled(boolean contentCompressionEnabled)Determines whether the target server is requested to compress content.RequestConfig.BuildersetCookieSpec(java.lang.String cookieSpec)Determines the name of the cookie specification to be used for HTTP state management.RequestConfig.BuildersetDefaultKeepAlive(long defaultKeepAlive, java.util.concurrent.TimeUnit timeUnit)RequestConfig.BuildersetExpectContinueEnabled(boolean expectContinueEnabled)Determines whether the 'Expect: 100-Continue' handshake is enabled for entity enclosing methods.RequestConfig.BuildersetH2Priority(org.apache.hc.core5.http2.priority.PriorityValue priority)Sets HTTP/2+ request priority.RequestConfig.BuildersetHardCancellationEnabled(boolean hardCancellationEnabled)Determines whether request cancellation, such as throughFuture#cancel(boolean), should kill the underlying connection.RequestConfig.BuildersetMaxRedirects(int maxRedirects)Returns the maximum number of redirects to be followed.RequestConfig.BuildersetProtocolUpgradeEnabled(boolean protocolUpgradeEnabled)Determines whether the client server should automatically attempt to upgrade to a safer or a newer version of the protocol, whenever possible.RequestConfig.BuildersetProxy(org.apache.hc.core5.http.HttpHost proxy)Returns HTTP proxy to be used for request execution.RequestConfig.BuildersetProxyPreferredAuthSchemes(java.util.Collection<java.lang.String> proxyPreferredAuthSchemes)Determines the order of preference for supported authentication schemes by their names when authenticating with the proxy host.RequestConfig.BuildersetRedirectsEnabled(boolean redirectsEnabled)Determines whether redirects should be handled automatically.RequestConfig.BuildersetResponseTimeout(long responseTimeout, java.util.concurrent.TimeUnit timeUnit)RequestConfig.BuildersetResponseTimeout(org.apache.hc.core5.util.Timeout responseTimeout)Determines the timeout until arrival of a response from the opposite endpoint.RequestConfig.BuildersetTargetPreferredAuthSchemes(java.util.Collection<java.lang.String> targetPreferredAuthSchemes)Determines the order of preference for supported authentication schemes by their names when authenticating with the target host.RequestConfig.BuildersetUnixDomainSocket(java.nio.file.Path unixDomainSocket)Sets the Unix Domain Socket path to use for the connection.
-
-
-
Field Detail
-
expectContinueEnabled
private boolean expectContinueEnabled
-
proxy
private org.apache.hc.core5.http.HttpHost proxy
-
cookieSpec
private java.lang.String cookieSpec
-
redirectsEnabled
private boolean redirectsEnabled
-
circularRedirectsAllowed
private boolean circularRedirectsAllowed
-
maxRedirects
private int maxRedirects
-
authenticationEnabled
private boolean authenticationEnabled
-
targetPreferredAuthSchemes
private java.util.Collection<java.lang.String> targetPreferredAuthSchemes
-
proxyPreferredAuthSchemes
private java.util.Collection<java.lang.String> 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
-
protocolUpgradeEnabled
private boolean protocolUpgradeEnabled
-
unixDomainSocket
private java.nio.file.Path unixDomainSocket
-
h2Priority
private org.apache.hc.core5.http2.priority.PriorityValue h2Priority
-
-
Method Detail
-
setExpectContinueEnabled
public RequestConfig.Builder setExpectContinueEnabled(boolean expectContinueEnabled)
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- Returns:
- this instance.
-
setProxy
public RequestConfig.Builder setProxy(org.apache.hc.core5.http.HttpHost proxy)
Returns HTTP proxy to be used for request execution.Default:
null- Returns:
- this instance.
-
setCookieSpec
public RequestConfig.Builder setCookieSpec(java.lang.String cookieSpec)
Determines the name of the cookie specification to be used for HTTP state management.Default:
null- Returns:
- this instance.
-
setRedirectsEnabled
public RequestConfig.Builder setRedirectsEnabled(boolean redirectsEnabled)
Determines whether redirects should be handled automatically.Default:
true- Returns:
- this instance.
-
setCircularRedirectsAllowed
public RequestConfig.Builder setCircularRedirectsAllowed(boolean circularRedirectsAllowed)
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- Returns:
- this instance.
-
setMaxRedirects
public RequestConfig.Builder setMaxRedirects(int maxRedirects)
Returns the maximum number of redirects to be followed. The limit on number of redirects is intended to prevent infinite loops.Default:
50- Returns:
- this instance.
-
setAuthenticationEnabled
public RequestConfig.Builder setAuthenticationEnabled(boolean authenticationEnabled)
Determines whether authentication should be handled automatically.Default:
true- Returns:
- this instance.
-
setTargetPreferredAuthSchemes
public RequestConfig.Builder setTargetPreferredAuthSchemes(java.util.Collection<java.lang.String> targetPreferredAuthSchemes)
Determines the order of preference for supported authentication schemes by their names when authenticating with the target host.Default:
null- Returns:
- this instance.
-
setProxyPreferredAuthSchemes
public RequestConfig.Builder setProxyPreferredAuthSchemes(java.util.Collection<java.lang.String> proxyPreferredAuthSchemes)
Determines the order of preference for supported authentication schemes by their names when authenticating with the proxy host.Default:
null- Returns:
- this instance.
-
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.
- Returns:
- this instance.
-
setConnectionRequestTimeout
public RequestConfig.Builder setConnectionRequestTimeout(long connectionRequestTimeout, java.util.concurrent.TimeUnit timeUnit)
- Returns:
- this instance.
- See Also:
setConnectionRequestTimeout(Timeout)
-
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 asSSLorTLSprotocol negotiation).A timeout value of zero is interpreted as an infinite timeout.
Default: 3 minutes
- Returns:
- this instance.
-
setConnectTimeout
@Deprecated public RequestConfig.Builder setConnectTimeout(long connectTimeout, java.util.concurrent.TimeUnit timeUnit)
Deprecated.- Returns:
- this instance.
- See Also:
setConnectTimeout(Timeout)
-
setResponseTimeout
public RequestConfig.Builder setResponseTimeout(org.apache.hc.core5.util.Timeout responseTimeout)
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.
This parameter overrides the socket timeout setting applied at the connection management or I/O layers for the duration of a message exchange.
Please note that response timeout is not a deadline. Its absolute value can be exceeded, for example, in case of automatic request re-execution. Please make sure the automatic request re-execution policy has been configured appropriately.
Default:
null- Returns:
- this instance.
- Since:
- 5.0
-
setResponseTimeout
public RequestConfig.Builder setResponseTimeout(long responseTimeout, java.util.concurrent.TimeUnit timeUnit)
- See Also:
setResponseTimeout(Timeout)
-
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-Aliveresponse header.A negative value is interpreted as an infinite keep-alive period.
Default: 3 minutes
- Returns:
- this instance.
- Since:
- 5.0
-
setDefaultKeepAlive
public RequestConfig.Builder setDefaultKeepAlive(long defaultKeepAlive, java.util.concurrent.TimeUnit timeUnit)
- Returns:
- this instance.
- See Also:
setConnectionKeepAlive(TimeValue)
-
setContentCompressionEnabled
public RequestConfig.Builder setContentCompressionEnabled(boolean contentCompressionEnabled)
Determines whether the target server is requested to compress content.Default:
true- Returns:
- this instance.
- Since:
- 4.5
-
setHardCancellationEnabled
public RequestConfig.Builder setHardCancellationEnabled(boolean hardCancellationEnabled)
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- Returns:
- this instance.
- Since:
- 5.0
-
setProtocolUpgradeEnabled
public RequestConfig.Builder setProtocolUpgradeEnabled(boolean protocolUpgradeEnabled)
Determines whether the client server should automatically attempt to upgrade to a safer or a newer version of the protocol, whenever possible.Presently supported: HTTP/1.1 TLS upgrade
Default:
true- Returns:
- this instance.
- Since:
- 5.4
-
setUnixDomainSocket
public RequestConfig.Builder setUnixDomainSocket(java.nio.file.Path unixDomainSocket)
Sets the Unix Domain Socket path to use for the connection.When set, the connection will use the specified Unix Domain Socket instead of a TCP socket. This is useful for communicating with local services like Docker or systemd.
Default:
null- Returns:
- this instance.
- Since:
- 5.6
-
setH2Priority
@Experimental public RequestConfig.Builder setH2Priority(org.apache.hc.core5.http2.priority.PriorityValue priority)
Sets HTTP/2+ request priority. Ifnull, the header is not emitted.- Since:
- 5.6
-
build
public RequestConfig build()
-
-