Top Description Inners Fields Constructors Methods
org.apache.http.client.config

public Class RequestConfig

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Annotations
@Contract
threading:IMMUTABLE
Imports
java.net.InetAddress, java.util.Collection, org.apache.http.HttpHost, org.apache.http.annotation.Contract, .ThreadingBehavior

Immutable class encapsulating request configuration items. The default setting for stale connection checking changed to false, and the feature was deprecated starting with version 4.4.

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 int
private final int
private final boolean
private final String
public static final RequestConfig
private final boolean
private final InetAddress
private final int
private final boolean
private final HttpHost
private final Collection<String>
private final boolean
private final boolean
private final int
private final boolean
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 InetAddress localAddress, final boolean staleConnectionCheckEnabled, final String cookieSpec, final boolean redirectsEnabled, final boolean relativeRedirectsAllowed, final boolean circularRedirectsAllowed, final int maxRedirects, final boolean authenticationEnabled, final Collection<String> targetPreferredAuthSchemes, final Collection<String> proxyPreferredAuthSchemes, final int connectionRequestTimeout, final int connectTimeout, final int socketTimeout, final boolean contentCompressionEnabled, final boolean normalizeUri)

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 int
getConnectionRequestTimeout()

Returns the timeout in milliseconds used when requesting a connection from the connection manager.

public int
getConnectTimeout()

Determines the timeout in milliseconds until a connection is established.

public String
getCookieSpec()

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

public InetAddress
getLocalAddress()

Returns local address to be used for request execution.

public int
getMaxRedirects()

Returns the maximum number of redirects to be followed.

public HttpHost
getProxy()

Returns HTTP proxy to be used for request execution.

public Collection<String>
getProxyPreferredAuthSchemes()

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

public int
getSocketTimeout()

Defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets).

public Collection<String>
getTargetPreferredAuthSchemes()

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

public boolean
isAuthenticationEnabled()

Determines whether authentication should be handled automatically.

public boolean
isCircularRedirectsAllowed()

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

public boolean
isContentCompressionEnabled()

Determines whether the target server is requested to compress content.

public boolean
isDecompressionEnabled()

Deprecated (4.5) Use isContentCompressionEnabled()
Determines whether compressed entities should be decompressed automatically.
public boolean
isExpectContinueEnabled()

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

public boolean
isNormalizeUri()

Determines whether client should normalize URIs in requests or not.

public boolean
isRedirectsEnabled()

Determines whether redirects should be handled automatically.

public boolean
isRelativeRedirectsAllowed()

Determines whether relative redirects should be rejected.

public boolean
isStaleConnectionCheckEnabled()

Determines whether stale connection check is to be used.
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
connectionRequestTimeoutback to summary
private final int connectionRequestTimeout
connectTimeoutback to summary
private final int connectTimeout
contentCompressionEnabledback to summary
private final boolean contentCompressionEnabled
cookieSpecback to summary
private final String cookieSpec
DEFAULTback to summary
public static final RequestConfig DEFAULT
expectContinueEnabledback to summary
private final boolean expectContinueEnabled
localAddressback to summary
private final InetAddress localAddress
maxRedirectsback to summary
private final int maxRedirects
normalizeUriback to summary
private final boolean normalizeUri
proxyback to summary
private final HttpHost proxy
proxyPreferredAuthSchemesback to summary
private final Collection<String> proxyPreferredAuthSchemes
redirectsEnabledback to summary
private final boolean redirectsEnabled
relativeRedirectsAllowedback to summary
private final boolean relativeRedirectsAllowed
socketTimeoutback to summary
private final int socketTimeout
staleConnectionCheckEnabledback to summary
private final boolean staleConnectionCheckEnabled
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 InetAddress localAddress, final boolean staleConnectionCheckEnabled, final String cookieSpec, final boolean redirectsEnabled, final boolean relativeRedirectsAllowed, final boolean circularRedirectsAllowed, final int maxRedirects, final boolean authenticationEnabled, final Collection<String> targetPreferredAuthSchemes, final Collection<String> proxyPreferredAuthSchemes, final int connectionRequestTimeout, final int connectTimeout, final int socketTimeout, final boolean contentCompressionEnabled, final boolean normalizeUri)

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()
getConnectionRequestTimeoutback to summary
public int getConnectionRequestTimeout()

Returns the timeout in milliseconds used when requesting a connection from the connection manager.

A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default if applicable).

Default: -1

getConnectTimeoutback to summary
public int getConnectTimeout()

Determines the timeout in milliseconds until a connection is established.

A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default if applicable).

Default: -1

getCookieSpecback to summary
public String getCookieSpec()

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

Default: null

getLocalAddressback to summary
public InetAddress getLocalAddress()

Returns local address to be used for request execution.

On machines with multiple network interfaces, this parameter can be used to select the network interface from which the connection originates.

Default: null

getMaxRedirectsback to summary
public int getMaxRedirects()

Returns the maximum number of redirects to be followed. The limit on number of redirects is intended to prevent infinite loops.

Default: 50

getProxyback to summary
public HttpHost getProxy()

Returns HTTP proxy to be used for request execution.

Default: null

getProxyPreferredAuthSchemesback to summary
public Collection<String> getProxyPreferredAuthSchemes()

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

Default: null

getSocketTimeoutback to summary
public int getSocketTimeout()

Defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets).

A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default if applicable).

Default: -1

getTargetPreferredAuthSchemesback to summary
public Collection<String> getTargetPreferredAuthSchemes()

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

Default: null

isAuthenticationEnabledback to summary
public boolean isAuthenticationEnabled()

Determines whether authentication should be handled automatically.

Default: true

isCircularRedirectsAllowedback to summary
public boolean isCircularRedirectsAllowed()

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

isContentCompressionEnabledback to summary
public boolean isContentCompressionEnabled()

Determines whether the target server is requested to compress content.

Default: true

Since
4.5
isDecompressionEnabledback to summary
public boolean isDecompressionEnabled()

Deprecated

(4.5) Use isContentCompressionEnabled()

Determines whether compressed entities should be decompressed automatically.

Default: true

Annotations
@Deprecated
Since
4.4
isExpectContinueEnabledback to summary
public boolean isExpectContinueEnabled()

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

isNormalizeUriback to summary
public boolean isNormalizeUri()

Determines whether client should normalize URIs in requests or not.

Default: true

Since
4.5.8
isRedirectsEnabledback to summary
public boolean isRedirectsEnabled()

Determines whether redirects should be handled automatically.

Default: true

isRelativeRedirectsAllowedback to summary
public boolean isRelativeRedirectsAllowed()

Determines whether relative redirects should be rejected. HTTP specification requires the location value be an absolute URI.

Default: true

isStaleConnectionCheckEnabledback to summary
public boolean isStaleConnectionCheckEnabled()

Determines whether stale connection check is to be used. The stale connection check can cause up to 30 millisecond overhead per request and should be used only when appropriate. For performance critical operations this check should be disabled.

Default: false since 4.4

Annotations
@Deprecated
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.http.client.config back to summary

public Class RequestConfig.Builder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private int
private int
private boolean
private String
private boolean
private InetAddress
private int
private boolean
private HttpHost
private Collection<String>
private boolean
private boolean
private int
private boolean
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)

public RequestConfig.Builder
setCircularRedirectsAllowed(final boolean circularRedirectsAllowed)

public RequestConfig.Builder
setConnectionRequestTimeout(final int connectionRequestTimeout)

public RequestConfig.Builder
setConnectTimeout(final int connectTimeout)

public RequestConfig.Builder
setContentCompressionEnabled(final boolean contentCompressionEnabled)

public RequestConfig.Builder
setCookieSpec(final String cookieSpec)

public RequestConfig.Builder
setDecompressionEnabled(final boolean decompressionEnabled)

Deprecated (4.5) Set setContentCompressionEnabled(boolean) to false and add the Accept-Encoding request header.
public RequestConfig.Builder
setExpectContinueEnabled(final boolean expectContinueEnabled)

public RequestConfig.Builder
setLocalAddress(final InetAddress localAddress)

public RequestConfig.Builder
setMaxRedirects(final int maxRedirects)

public RequestConfig.Builder
setNormalizeUri(final boolean normalizeUri)

public RequestConfig.Builder
setProxy(final HttpHost proxy)

public RequestConfig.Builder
setProxyPreferredAuthSchemes(final Collection<String> proxyPreferredAuthSchemes)

public RequestConfig.Builder
setRedirectsEnabled(final boolean redirectsEnabled)

public RequestConfig.Builder
setRelativeRedirectsAllowed(final boolean relativeRedirectsAllowed)

public RequestConfig.Builder
setSocketTimeout(final int socketTimeout)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

authenticationEnabledback to summary
private boolean authenticationEnabled
circularRedirectsAllowedback to summary
private boolean circularRedirectsAllowed
connectionRequestTimeoutback to summary
private int connectionRequestTimeout
connectTimeoutback to summary
private int connectTimeout
contentCompressionEnabledback to summary
private boolean contentCompressionEnabled
cookieSpecback to summary
private String cookieSpec
expectContinueEnabledback to summary
private boolean expectContinueEnabled
localAddressback to summary
private InetAddress localAddress
maxRedirectsback to summary
private int maxRedirects
normalizeUriback to summary
private boolean normalizeUri
proxyback to summary
private HttpHost proxy
proxyPreferredAuthSchemesback to summary
private Collection<String> proxyPreferredAuthSchemes
redirectsEnabledback to summary
private boolean redirectsEnabled
relativeRedirectsAllowedback to summary
private boolean relativeRedirectsAllowed
socketTimeoutback to summary
private int socketTimeout
staleConnectionCheckEnabledback to summary
private boolean staleConnectionCheckEnabled
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)
setCircularRedirectsAllowedback to summary
public RequestConfig.Builder setCircularRedirectsAllowed(final boolean circularRedirectsAllowed)
setConnectionRequestTimeoutback to summary
public RequestConfig.Builder setConnectionRequestTimeout(final int connectionRequestTimeout)
setConnectTimeoutback to summary
public RequestConfig.Builder setConnectTimeout(final int connectTimeout)
setContentCompressionEnabledback to summary
public RequestConfig.Builder setContentCompressionEnabled(final boolean contentCompressionEnabled)
setCookieSpecback to summary
public RequestConfig.Builder setCookieSpec(final String cookieSpec)
setDecompressionEnabledback to summary
public RequestConfig.Builder setDecompressionEnabled(final boolean decompressionEnabled)

Deprecated

(4.5) Set setContentCompressionEnabled(boolean) to false and add the Accept-Encoding request header.

Annotations
@Deprecated
setExpectContinueEnabledback to summary
public RequestConfig.Builder setExpectContinueEnabled(final boolean expectContinueEnabled)
setLocalAddressback to summary
public RequestConfig.Builder setLocalAddress(final InetAddress localAddress)
setMaxRedirectsback to summary
public RequestConfig.Builder setMaxRedirects(final int maxRedirects)
setNormalizeUriback to summary
public RequestConfig.Builder setNormalizeUri(final boolean normalizeUri)
setProxyback to summary
public RequestConfig.Builder setProxy(final HttpHost proxy)
setProxyPreferredAuthSchemesback to summary
public RequestConfig.Builder setProxyPreferredAuthSchemes(final Collection<String> proxyPreferredAuthSchemes)
setRedirectsEnabledback to summary
public RequestConfig.Builder setRedirectsEnabled(final boolean redirectsEnabled)
setRelativeRedirectsAllowedback to summary
public RequestConfig.Builder setRelativeRedirectsAllowed(final boolean relativeRedirectsAllowed)
setSocketTimeoutback to summary
public RequestConfig.Builder setSocketTimeout(final int socketTimeout)
setStaleConnectionCheckEnabledback to summary
public RequestConfig.Builder setStaleConnectionCheckEnabled(final boolean staleConnectionCheckEnabled)
Annotations
@Deprecated
setTargetPreferredAuthSchemesback to summary
public RequestConfig.Builder setTargetPreferredAuthSchemes(final Collection<String> targetPreferredAuthSchemes)