org.apache.commons.httpclient.params

Class HttpMethodParams

public class HttpMethodParams extends DefaultHttpParams

This class represents a collection of HTTP protocol parameters applicable to {@link org.apache.commons.httpclient.HttpMethod HTTP methods}. Protocol parameters may be linked together to form a hierarchy. If a particular parameter value has not been explicitly defined in the collection itself, its value will be drawn from the parent collection of parameters.

Since: 3.0

Version: $Revision: 354155 $

Author: Oleg Kalnichevski Christian Kohlschuetter

Field Summary
static StringBUFFER_WARN_TRIGGER_LIMIT
Sets the maximum buffered response size (in bytes) that triggers no warning.
static StringCOOKIE_POLICY
Defines {@link CookiePolicy cookie policy} to be used for cookie management.
static StringCREDENTIAL_CHARSET
Defines the charset to be used when encoding {@link org.apache.commons.httpclient.Credentials}.
static StringDATE_PATTERNS
The key used to look up the date patterns used for parsing.
static StringHEAD_BODY_CHECK_TIMEOUT
Sets period of time in milliseconds to wait for a content body sent in response to {@link org.apache.commons.httpclient.methods.HeadMethod HEAD method} from a non-compliant server.
static StringHTTP_CONTENT_CHARSET
Defines the charset to be used for encoding content body.
static StringHTTP_ELEMENT_CHARSET
Defines the charset to be used for encoding HTTP protocol elements.
static StringMULTIPART_BOUNDARY
Sets the value to use as the multipart boundary.
static StringPROTOCOL_VERSION
Defines the {@link HttpVersion HTTP protocol version} used by {@link org.apache.commons.httpclient.HttpMethod HTTP methods} per default.
static StringREJECT_HEAD_BODY
Defines whether the content body sent in response to {@link org.apache.commons.httpclient.methods.HeadMethod} should be rejected.
static StringRETRY_HANDLER
Sets the method retry handler parameter.
static StringSINGLE_COOKIE_HEADER
Defines whether {@link org.apache.commons.httpclient.Cookie cookies} should be put on a single {@link org.apache.commons.httpclient.Header response header}.
static StringSO_TIMEOUT
Sets the socket timeout (SO_TIMEOUT) in milliseconds to be used when executing the method.
static StringSTATUS_LINE_GARBAGE_LIMIT
Defines the maximum number of ignorable lines before we expect a HTTP response's status code.
static StringSTRICT_TRANSFER_ENCODING
Defines whether responses with an invalid Transfer-Encoding header should be rejected.
static StringUNAMBIGUOUS_STATUS_LINE
Defines whether {@link org.apache.commons.httpclient.HttpMethod HTTP methods} should reject ambiguous {@link org.apache.commons.httpclient.StatusLine HTTP status line}.
static StringUSER_AGENT
Defines the content of the User-Agent header used by {@link org.apache.commons.httpclient.HttpMethod HTTP methods}.
static StringUSE_EXPECT_CONTINUE

Activates 'Expect: 100-Continue' handshake for the {@link org.apache.commons.httpclient.methods.ExpectContinueMethod entity enclosing methods}.

static StringVIRTUAL_HOST
Defines the virtual host name.
static StringWARN_EXTRA_INPUT
Defines HttpClient's behavior when a response provides more bytes than expected (specified with Content-Length, for example).
Constructor Summary
HttpMethodParams()
Creates a new collection of parameters with the collection returned by {@link #getDefaultParams()} as a parent.
HttpMethodParams(HttpParams defaults)
Creates a new collection of parameters with the given parent.
Method Summary
StringgetContentCharset()
Returns the default charset to be used for writing content body, when no charset explicitly specified.
StringgetCookiePolicy()
Returns {@link CookiePolicy cookie policy} to be used by the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} this collection of parameters applies to.
StringgetCredentialCharset()
Returns the charset to be used for {@link org.apache.commons.httpclient.Credentials}.
StringgetHttpElementCharset()
Returns the charset to be used for writing HTTP headers.
intgetSoTimeout()
Returns the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data.
HttpVersiongetVersion()
Returns {@link HttpVersion HTTP protocol version} to be used by the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} that this collection of parameters applies to.
StringgetVirtualHost()
Returns the virtual host name.
voidmakeLenient()
Makes the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} attempt to mimic the exact behaviour of commonly used HTTP agents, which many HTTP servers expect, even though such behaviour may violate the HTTP protocol specification (RFC 2616 and other relevant RFCs).
voidmakeStrict()
Makes the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} strictly follow the HTTP protocol specification (RFC 2616 and other relevant RFCs).
voidsetContentCharset(String charset)
Sets the default charset to be used for writing content body, when no charset explicitly specified.
voidsetCookiePolicy(String policy)
Assigns the {@link CookiePolicy cookie policy} to be used by the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} this collection of parameters applies to.
voidsetCredentialCharset(String charset)
Sets the charset to be used for writing HTTP headers.
voidsetHttpElementCharset(String charset)
Sets the charset to be used for writing HTTP headers.
voidsetSoTimeout(int timeout)
Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data.
voidsetVersion(HttpVersion version)
Assigns the {@link HttpVersion HTTP protocol version} to be used by the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} that this collection of parameters applies to.
voidsetVirtualHost(String hostname)
Sets the virtual host name.

Field Detail

BUFFER_WARN_TRIGGER_LIMIT

public static final String BUFFER_WARN_TRIGGER_LIMIT
Sets the maximum buffered response size (in bytes) that triggers no warning. Buffered responses exceeding this size will trigger a warning in the log.

This parameter expects a value if type {@link Integer}.

COOKIE_POLICY

public static final String COOKIE_POLICY
Defines {@link CookiePolicy cookie policy} to be used for cookie management.

This parameter expects a value of type {@link String}.

CREDENTIAL_CHARSET

public static final String CREDENTIAL_CHARSET
Defines the charset to be used when encoding {@link org.apache.commons.httpclient.Credentials}. If not defined then the {@link #HTTP_ELEMENT_CHARSET} should be used.

This parameter expects a value of type {@link String}.

DATE_PATTERNS

public static final String DATE_PATTERNS
The key used to look up the date patterns used for parsing. The String patterns are stored in a {@link java.util.Collection} and must be compatible with {@link java.text.SimpleDateFormat}.

This parameter expects a value of type {@link java.util.Collection}.

HEAD_BODY_CHECK_TIMEOUT

public static final String HEAD_BODY_CHECK_TIMEOUT
Sets period of time in milliseconds to wait for a content body sent in response to {@link org.apache.commons.httpclient.methods.HeadMethod HEAD method} from a non-compliant server. If the parameter is not set or set to -1 non-compliant response body check is disabled.

This parameter expects a value of type {@link Integer}.

HTTP_CONTENT_CHARSET

public static final String HTTP_CONTENT_CHARSET
Defines the charset to be used for encoding content body.

This parameter expects a value of type {@link String}.

HTTP_ELEMENT_CHARSET

public static final String HTTP_ELEMENT_CHARSET
Defines the charset to be used for encoding HTTP protocol elements.

This parameter expects a value of type {@link String}.

MULTIPART_BOUNDARY

public static final String MULTIPART_BOUNDARY
Sets the value to use as the multipart boundary.

This parameter expects a value if type {@link String}.

See Also: MultipartRequestEntity

PROTOCOL_VERSION

public static final String PROTOCOL_VERSION
Defines the {@link HttpVersion HTTP protocol version} used by {@link org.apache.commons.httpclient.HttpMethod HTTP methods} per default.

This parameter expects a value of type {@link HttpVersion}.

REJECT_HEAD_BODY

public static final String REJECT_HEAD_BODY
Defines whether the content body sent in response to {@link org.apache.commons.httpclient.methods.HeadMethod} should be rejected.

This parameter expects a value of type {@link Boolean}.

RETRY_HANDLER

public static final String RETRY_HANDLER
Sets the method retry handler parameter.

This parameter expects a value of type {@link org.apache.commons.httpclient.HttpMethodRetryHandler}.

SINGLE_COOKIE_HEADER

public static final String SINGLE_COOKIE_HEADER
Defines whether {@link org.apache.commons.httpclient.Cookie cookies} should be put on a single {@link org.apache.commons.httpclient.Header response header}.

This parameter expects a value of type {@link Boolean}.

SO_TIMEOUT

public static final String SO_TIMEOUT
Sets the socket timeout (SO_TIMEOUT) in milliseconds to be used when executing the method. A timeout value of zero is interpreted as an infinite timeout.

This parameter expects a value of type {@link Integer}.

See Also: java.net.SocketOptions#SO_TIMEOUT

STATUS_LINE_GARBAGE_LIMIT

public static final String STATUS_LINE_GARBAGE_LIMIT
Defines the maximum number of ignorable lines before we expect a HTTP response's status code.

With HTTP/1.1 persistent connections, the problem arises that broken scripts could return a wrong Content-Length (there are more bytes sent than specified).
Unfortunately, in some cases, this is not possible after the bad response, but only before the next one.
So, HttpClient must be able to skip those surplus lines this way.

Set this to 0 to disallow any garbage/empty lines before the status line.
To specify no limit, use {@link java.lang.Integer#MAX_VALUE} (default in lenient mode).

This parameter expects a value of type {@link Integer}.

STRICT_TRANSFER_ENCODING

public static final String STRICT_TRANSFER_ENCODING
Defines whether responses with an invalid Transfer-Encoding header should be rejected.

This parameter expects a value of type {@link Boolean}.

UNAMBIGUOUS_STATUS_LINE

public static final String UNAMBIGUOUS_STATUS_LINE
Defines whether {@link org.apache.commons.httpclient.HttpMethod HTTP methods} should reject ambiguous {@link org.apache.commons.httpclient.StatusLine HTTP status line}.

This parameter expects a value of type {@link Boolean}.

USER_AGENT

public static final String USER_AGENT
Defines the content of the User-Agent header used by {@link org.apache.commons.httpclient.HttpMethod HTTP methods}.

This parameter expects a value of type {@link String}.

USE_EXPECT_CONTINUE

public static final String USE_EXPECT_CONTINUE

Activates 'Expect: 100-Continue' handshake for the {@link org.apache.commons.httpclient.methods.ExpectContinueMethod entity enclosing methods}. The purpose of the 'Expect: 100-Continue' handshake 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 noticable peformance 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.

This parameter expects a value of type {@link Boolean}.

VIRTUAL_HOST

public static final String VIRTUAL_HOST
Defines the virtual host name.

This parameter expects a value of type {@link java.lang.String}.

WARN_EXTRA_INPUT

public static final String WARN_EXTRA_INPUT
Defines HttpClient's behavior when a response provides more bytes than expected (specified with Content-Length, for example).

Such surplus data makes the HTTP connection unreliable for keep-alive requests, as malicious response data (faked headers etc.) can lead to undesired results on the next request using that connection.

If this parameter is set to true, any detection of extra input data will generate a warning in the log.

This parameter expects a value of type {@link Boolean}.

Constructor Detail

HttpMethodParams

public HttpMethodParams()
Creates a new collection of parameters with the collection returned by {@link #getDefaultParams()} as a parent. The collection will defer to its parent for a default value if a particular parameter is not explicitly set in the collection itself.

See Also: HttpMethodParams

HttpMethodParams

public HttpMethodParams(HttpParams defaults)
Creates a new collection of parameters with the given parent. The collection will defer to its parent for a default value if a particular parameter is not explicitly set in the collection itself.

Parameters: defaults the parent collection to defer to, if a parameter is not explictly set in the collection itself.

See Also: HttpMethodParams

Method Detail

getContentCharset

public String getContentCharset()
Returns the default charset to be used for writing content body, when no charset explicitly specified.

Returns: The charset

getCookiePolicy

public String getCookiePolicy()
Returns {@link CookiePolicy cookie policy} to be used by the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} this collection of parameters applies to.

Returns: {@link CookiePolicy cookie policy}

getCredentialCharset

public String getCredentialCharset()
Returns the charset to be used for {@link org.apache.commons.httpclient.Credentials}. If not configured the {@link #HTTP_ELEMENT_CHARSET HTTP element charset} is used.

Returns: The charset

getHttpElementCharset

public String getHttpElementCharset()
Returns the charset to be used for writing HTTP headers.

Returns: The charset

getSoTimeout

public int getSoTimeout()
Returns the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout.

Returns: timeout in milliseconds

getVersion

public HttpVersion getVersion()
Returns {@link HttpVersion HTTP protocol version} to be used by the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} that this collection of parameters applies to.

Returns: {@link HttpVersion HTTP protocol version}

getVirtualHost

public String getVirtualHost()
Returns the virtual host name.

Returns: The virtual host name

makeLenient

public void makeLenient()
Makes the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} attempt to mimic the exact behaviour of commonly used HTTP agents, which many HTTP servers expect, even though such behaviour may violate the HTTP protocol specification (RFC 2616 and other relevant RFCs).

makeStrict

public void makeStrict()
Makes the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} strictly follow the HTTP protocol specification (RFC 2616 and other relevant RFCs). It must be noted that popular HTTP agents have different degree of HTTP protocol compliance and some HTTP serves are programmed to expect the behaviour that does not strictly adhere to the HTTP specification.

setContentCharset

public void setContentCharset(String charset)
Sets the default charset to be used for writing content body, when no charset explicitly specified.

Parameters: charset The charset

setCookiePolicy

public void setCookiePolicy(String policy)
Assigns the {@link CookiePolicy cookie policy} to be used by the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} this collection of parameters applies to.

Parameters: policy the {@link CookiePolicy cookie policy}

setCredentialCharset

public void setCredentialCharset(String charset)
Sets the charset to be used for writing HTTP headers.

Parameters: charset The charset

setHttpElementCharset

public void setHttpElementCharset(String charset)
Sets the charset to be used for writing HTTP headers.

Parameters: charset The charset

setSoTimeout

public void setSoTimeout(int timeout)
Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout.

Parameters: timeout Timeout in milliseconds

setVersion

public void setVersion(HttpVersion version)
Assigns the {@link HttpVersion HTTP protocol version} to be used by the {@link org.apache.commons.httpclient.HttpMethod HTTP methods} that this collection of parameters applies to.

Parameters: version the {@link HttpVersion HTTP protocol version}

setVirtualHost

public void setVirtualHost(String hostname)
Sets the virtual host name.

Parameters: hostname The host name

Copyright (c) 1999-2005 - Apache Software Foundation