Top Description Inners Fields Constructors Methods
org.apache.hc.client5.http.config

public Class RequestConfig

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Annotations
@Contract
threading:IMMUTABLE
Imports
java.util.Collection, java.util.concurrent.TimeUnit, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.HttpHost, org.apache.hc.core5.util.TimeValue, .Timeout

Immutable class encapsulating request configuration items.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private final TimeValue
private final Timeout
private final Timeout
private final boolean
private final String
public static final RequestConfig
private static final TimeValue
private static final Timeout
private final boolean
private final boolean
private final int
private final HttpHost
private final Collection<String>
private final boolean
private final Timeout
private final Collection<String>

Constructor Summary

AccessConstructor and Description
protected
RequestConfig()

Intended for CDI compatibility

pack-priv
RequestConfig(final boolean expectContinueEnabled, final HttpHost proxy, final String cookieSpec, final boolean redirectsEnabled, final boolean circularRedirectsAllowed, final int maxRedirects, final boolean authenticationEnabled, final Collection<String> targetPreferredAuthSchemes, final Collection<String> proxyPreferredAuthSchemes, final Timeout connectionRequestTimeout, final Timeout connectTimeout, final Timeout responseTimeout, final TimeValue connectionKeepAlive, final boolean contentCompressionEnabled, final boolean hardCancellationEnabled)

Method Summary

Modifier and TypeMethod and Description
protected RequestConfig
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public static RequestConfig.Builder
copy(final RequestConfig config)

public static RequestConfig.Builder
public TimeValue
public Timeout
public Timeout
public String
public int
public HttpHost
public Collection<String>
public Timeout
public Collection<String>
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

authenticationEnabledback to summary
private final boolean authenticationEnabled
circularRedirectsAllowedback to summary
private final boolean circularRedirectsAllowed
connectionKeepAliveback to summary
private final TimeValue connectionKeepAlive
connectionRequestTimeoutback to summary
private final Timeout connectionRequestTimeout
connectTimeoutback to summary
private final Timeout connectTimeout
contentCompressionEnabledback to summary
private final boolean contentCompressionEnabled
cookieSpecback to summary
private final String cookieSpec
DEFAULTback to summary
public static final RequestConfig DEFAULT
DEFAULT_CONN_KEEP_ALIVEback to summary
private static final TimeValue DEFAULT_CONN_KEEP_ALIVE
DEFAULT_CONNECTION_REQUEST_TIMEOUTback to summary
private static final Timeout DEFAULT_CONNECTION_REQUEST_TIMEOUT
expectContinueEnabledback to summary
private final boolean expectContinueEnabled
hardCancellationEnabledback to summary
private final boolean hardCancellationEnabled
maxRedirectsback to summary
private final int maxRedirects
proxyback to summary
private final HttpHost proxy
proxyPreferredAuthSchemesback to summary
private final Collection<String> proxyPreferredAuthSchemes
redirectsEnabledback to summary
private final boolean redirectsEnabled
responseTimeoutback to summary
private final Timeout responseTimeout
targetPreferredAuthSchemesback to summary
private final Collection<String> targetPreferredAuthSchemes

Constructor Detail

RequestConfigback to summary
protected RequestConfig()

Intended for CDI compatibility

RequestConfigback to summary
pack-priv RequestConfig(final boolean expectContinueEnabled, final HttpHost proxy, final String cookieSpec, final boolean redirectsEnabled, final boolean circularRedirectsAllowed, final int maxRedirects, final boolean authenticationEnabled, final Collection<String> targetPreferredAuthSchemes, final Collection<String> proxyPreferredAuthSchemes, final Timeout connectionRequestTimeout, final Timeout connectTimeout, final Timeout responseTimeout, final TimeValue connectionKeepAlive, final boolean contentCompressionEnabled, final boolean hardCancellationEnabled)

Method Detail

cloneback to summary
protected RequestConfig clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:RequestConfig

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
copyback to summary
public static RequestConfig.Builder copy(final RequestConfig config)
Annotations
@SuppressWarnings:deprecation
customback to summary
public static RequestConfig.Builder custom()
getConnectionKeepAliveback to summary
public TimeValue getConnectionKeepAlive()
See Also
Builder#setConnectionKeepAlive(TimeValue)
getConnectionRequestTimeoutback to summary
public Timeout getConnectionRequestTimeout()
See Also
Builder#setConnectionRequestTimeout(Timeout)
getConnectTimeoutback to summary
public Timeout getConnectTimeout()
Annotations
@Deprecated
See Also
Builder#setConnectTimeout(Timeout)
getCookieSpecback to summary
public String getCookieSpec()
See Also
Builder#setCookieSpec(String)
getMaxRedirectsback to summary
public int getMaxRedirects()
See Also
Builder#setMaxRedirects(int)
getProxyback to summary
public HttpHost getProxy()
Annotations
@Deprecated
See Also
Builder#setProxy(HttpHost)
getProxyPreferredAuthSchemesback to summary
public Collection<String> getProxyPreferredAuthSchemes()
See Also
Builder#setProxyPreferredAuthSchemes(Collection)
getResponseTimeoutback to summary
public Timeout getResponseTimeout()
See Also
Builder#setResponseTimeout(Timeout)
getTargetPreferredAuthSchemesback to summary
public Collection<String> getTargetPreferredAuthSchemes()
See Also
Builder#setTargetPreferredAuthSchemes(Collection)
isAuthenticationEnabledback to summary
public boolean isAuthenticationEnabled()
See Also
Builder#setAuthenticationEnabled(boolean)
isCircularRedirectsAllowedback to summary
public boolean isCircularRedirectsAllowed()
See Also
Builder#setCircularRedirectsAllowed(boolean)
isContentCompressionEnabledback to summary
public boolean isContentCompressionEnabled()
See Also
Builder#setContentCompressionEnabled(boolean)
isExpectContinueEnabledback to summary
public boolean isExpectContinueEnabled()
See Also
Builder#setExpectContinueEnabled(boolean)
isHardCancellationEnabledback to summary
public boolean isHardCancellationEnabled()
See Also
Builder#setHardCancellationEnabled(boolean)
isRedirectsEnabledback to summary
public boolean isRedirectsEnabled()
See Also
Builder#setRedirectsEnabled(boolean)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.apache.hc.client5.http.config back to summary

public Class RequestConfig.Builder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private TimeValue
private Timeout
private Timeout
private boolean
private String
private boolean
private boolean
private int
private HttpHost
private Collection<String>
private boolean
private Timeout
private Collection<String>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public RequestConfig
public RequestConfig.Builder
setAuthenticationEnabled(final boolean authenticationEnabled)

Determines whether authentication should be handled automatically.

public RequestConfig.Builder
setCircularRedirectsAllowed(final boolean circularRedirectsAllowed)

Determines whether circular redirects (redirects to the same location) should be allowed.

public RequestConfig.Builder
setConnectionKeepAlive(final 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.

public RequestConfig.Builder
setConnectionRequestTimeout(final Timeout connectionRequestTimeout)

Returns the connection lease request timeout used when requesting a connection from the connection manager.

public RequestConfig.Builder
setConnectionRequestTimeout(final long connectionRequestTimeout, final TimeUnit timeUnit)

public RequestConfig.Builder
setConnectTimeout(final Timeout connectTimeout)

Determines the timeout until a new connection is fully established.
public RequestConfig.Builder
setConnectTimeout(final long connectTimeout, final TimeUnit timeUnit)

public RequestConfig.Builder
setContentCompressionEnabled(final boolean contentCompressionEnabled)

Determines whether the target server is requested to compress content.

public RequestConfig.Builder
setCookieSpec(final String cookieSpec)

Determines the name of the cookie specification to be used for HTTP state management.

public RequestConfig.Builder
setDefaultKeepAlive(final long defaultKeepAlive, final TimeUnit timeUnit)

public RequestConfig.Builder
setExpectContinueEnabled(final boolean expectContinueEnabled)

Determines whether the 'Expect: 100-Continue' handshake is enabled for entity enclosing methods.

public RequestConfig.Builder
setHardCancellationEnabled(final boolean hardCancellationEnabled)

Determines whether request cancellation, such as through Future#cancel(boolean), should kill the underlying connection.

public RequestConfig.Builder
setMaxRedirects(final int maxRedirects)

Returns the maximum number of redirects to be followed.

public RequestConfig.Builder
setProxy(final HttpHost proxy)

Returns HTTP proxy to be used for request execution.
public RequestConfig.Builder
setProxyPreferredAuthSchemes(final Collection<String> proxyPreferredAuthSchemes)

Determines the order of preference for supported authentication schemes by their names when authenticating with the proxy host.

public RequestConfig.Builder
setRedirectsEnabled(final boolean redirectsEnabled)

Determines whether redirects should be handled automatically.

public RequestConfig.Builder
setResponseTimeout(final Timeout responseTimeout)

Determines the timeout until arrival of a response from the opposite endpoint.

public RequestConfig.Builder
setResponseTimeout(final long responseTimeout, final TimeUnit timeUnit)

public RequestConfig.Builder
setTargetPreferredAuthSchemes(final Collection<String> targetPreferredAuthSchemes)

Determines the order of preference for supported authentication schemes by their names when authenticating with the target host.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

authenticationEnabledback to summary
private boolean authenticationEnabled
circularRedirectsAllowedback to summary
private boolean circularRedirectsAllowed
connectionKeepAliveback to summary
private TimeValue connectionKeepAlive
connectionRequestTimeoutback to summary
private Timeout connectionRequestTimeout
connectTimeoutback to summary
private Timeout connectTimeout
contentCompressionEnabledback to summary
private boolean contentCompressionEnabled
cookieSpecback to summary
private String cookieSpec
expectContinueEnabledback to summary
private boolean expectContinueEnabled
hardCancellationEnabledback to summary
private boolean hardCancellationEnabled
maxRedirectsback to summary
private int maxRedirects
proxyback to summary
private HttpHost proxy
proxyPreferredAuthSchemesback to summary
private Collection<String> proxyPreferredAuthSchemes
redirectsEnabledback to summary
private boolean redirectsEnabled
responseTimeoutback to summary
private Timeout responseTimeout
targetPreferredAuthSchemesback to summary
private Collection<String> targetPreferredAuthSchemes

Constructor Detail

Builderback to summary
pack-priv Builder()

Method Detail

buildback to summary
public RequestConfig build()
setAuthenticationEnabledback to summary
public RequestConfig.Builder setAuthenticationEnabled(final boolean authenticationEnabled)

Determines whether authentication should be handled automatically.

Default: true

setCircularRedirectsAllowedback to summary
public RequestConfig.Builder setCircularRedirectsAllowed(final 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 enabled

Default: false

setConnectionKeepAliveback to summary
public RequestConfig.Builder setConnectionKeepAlive(final 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.

A negative value is interpreted as an infinite keep-alive period.

Default: 3 minutes

Since
5.0
setConnectionRequestTimeoutback to summary
public RequestConfig.Builder setConnectionRequestTimeout(final Timeout connectionRequestTimeout)

Returns the connection lease request timeout used when requesting a connection from the connection manager.

Default: 3 minutes.

setConnectionRequestTimeoutback to summary
public RequestConfig.Builder setConnectionRequestTimeout(final long connectionRequestTimeout, final TimeUnit timeUnit)
See Also
setConnectionRequestTimeout(Timeout)
setConnectTimeoutback to summary
public RequestConfig.Builder setConnectTimeout(final Timeout connectTimeout)

Determines the timeout until a new connection is fully established. This may also include transport security negotiation exchanges such as SSL or TLS protocol negotiation).

A timeout value of zero is interpreted as an infinite timeout.

Default: 3 minutes

Annotations
@Deprecated
setConnectTimeoutback to summary
public RequestConfig.Builder setConnectTimeout(final long connectTimeout, final TimeUnit timeUnit)
Annotations
@Deprecated
See Also
setConnectTimeout(Timeout)
setContentCompressionEnabledback to summary
public RequestConfig.Builder setContentCompressionEnabled(final boolean contentCompressionEnabled)

Determines whether the target server is requested to compress content.

Default: true

Since
4.5
setCookieSpecback to summary
public RequestConfig.Builder setCookieSpec(final String cookieSpec)

Determines the name of the cookie specification to be used for HTTP state management.

Default: null

setDefaultKeepAliveback to summary
public RequestConfig.Builder setDefaultKeepAlive(final long defaultKeepAlive, final TimeUnit timeUnit)
See Also
setConnectionKeepAlive(TimeValue)
setExpectContinueEnabledback to summary
public RequestConfig.Builder setExpectContinueEnabled(final 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

setHardCancellationEnabledback to summary
public RequestConfig.Builder setHardCancellationEnabled(final boolean hardCancellationEnabled)

Determines whether request cancellation, such as through 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

Since
5.0
setMaxRedirectsback to summary
public RequestConfig.Builder setMaxRedirects(final 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

setProxyback to summary
public RequestConfig.Builder setProxy(final HttpHost proxy)

Returns HTTP proxy to be used for request execution.

Default: null

Annotations
@Deprecated
setProxyPreferredAuthSchemesback to summary
public RequestConfig.Builder setProxyPreferredAuthSchemes(final Collection<String> proxyPreferredAuthSchemes)

Determines the order of preference for supported authentication schemes by their names when authenticating with the proxy host.

Default: null

setRedirectsEnabledback to summary
public RequestConfig.Builder setRedirectsEnabled(final boolean redirectsEnabled)

Determines whether redirects should be handled automatically.

Default: true

setResponseTimeoutback to summary
public RequestConfig.Builder setResponseTimeout(final 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.

Default: null

Since
5.0
setResponseTimeoutback to summary
public RequestConfig.Builder setResponseTimeout(final long responseTimeout, final TimeUnit timeUnit)
See Also
setResponseTimeout(Timeout)
setTargetPreferredAuthSchemesback to summary
public RequestConfig.Builder setTargetPreferredAuthSchemes(final Collection<String> targetPreferredAuthSchemes)

Determines the order of preference for supported authentication schemes by their names when authenticating with the target host.

Default: null