org.apache.commons.httpclient
public class HeaderElement extends NameValuePair
One element of an HTTP header's value.
Some HTTP headers (such as the set-cookie header) have values that can be decomposed into multiple elements. Such headers must be in the following form:
header = [ element ] *( "," [ element ] ) element = name [ "=" [ value ] ] *( ";" [ param ] ) param = name [ "=" [ value ] ] name = token value = ( token | quoted-string ) token = 1*<any char except "=", ",", ";", <"> and white space> quoted-string = <"> *( text | quoted-char ) <"> text = any char except <"> quoted-char = "\" char
Any amount of white space is allowed between any part of the header, element or param and is ignored. A missing value in any element or param will be stored as the empty String; if the "=" is also missing null will be stored instead.
This class represents an individual header element, containing both a name/value pair (value may be null) and optionally a set of additional parameters.
This class also exposes a HeaderElement method for parsing a Header value into an array of elements.
Since: 1.0
Version: $Revision: 155418 $ $Date: 2005-02-26 08:01:52 -0500 (Sat, 26 Feb 2005) $
Constructor Summary | |
---|---|
HeaderElement()
Default constructor. | |
HeaderElement(String name, String value)
Constructor. | |
HeaderElement(String name, String value, NameValuePair[] parameters)
Constructor with name, value and parameters.
| |
HeaderElement(char[] chars, int offset, int length)
Constructor with array of characters.
| |
HeaderElement(char[] chars)
Constructor with array of characters.
|
Method Summary | |
---|---|
NameValuePair | getParameterByName(String name)
Returns parameter with the given name, if found. |
NameValuePair[] | getParameters()
Get parameters, if any.
|
static HeaderElement[] | parse(String headerValue)
This parses the value part of a header. |
static HeaderElement[] | parseElements(char[] headerValue)
This parses the value part of a header. |
static HeaderElement[] | parseElements(String headerValue)
This parses the value part of a header. |
Parameters: name my name value my (possibly null) value
Parameters: name my name value my (possibly null) value parameters my (possibly null) parameters
Parameters: chars the array of characters offset - the initial offset. length - the length.
Since: 3.0
Parameters: chars the array of characters
Since: 3.0
Parameters: name The name to search by.
Returns: NameValuePair parameter with the given name
Returns: parameters as an array of NameValuePairs
Since: 2.0
Deprecated: Use #parseElements(String).
This parses the value part of a header. The result is an array of HeaderElement objects.Parameters: headerValue the string representation of the header value (as received from the web server).
Returns: array of HeaderElements.
Throws: HttpException if the above syntax rules are violated.
Parameters: headerValue the array of char representation of the header value (as received from the web server).
Returns: array of HeaderElements.
Since: 3.0
Parameters: headerValue the string representation of the header value (as received from the web server).
Returns: array of HeaderElements.
Since: 3.0