HTTP Fields.
A collection of HTTP header and or Trailer fields.
This class is not synchronized and needs to be protected from
concurrent access.
This class is not synchronized as it is expected that modifications
will only be performed by a single thread.
__01Jan1970
public static final String __01Jan1970
__Accept
public static final String __Accept
Request Fields.
__AcceptCharset
public static final String __AcceptCharset
Request Fields.
__AcceptEncoding
public static final String __AcceptEncoding
Request Fields.
__AcceptLanguage
public static final String __AcceptLanguage
Request Fields.
__AcceptRanges
public static final String __AcceptRanges
Response Fields.
__Age
public static final String __Age
Response Fields.
__Allow
public static final String __Allow
Entity Fields.
__Authorization
public static final String __Authorization
Request Fields.
__COLON
public static final char[] __COLON
__CRLF
public static final char[] __CRLF
__CacheControl
public static final String __CacheControl
General Fields.
__Chunked
public static final String __Chunked
Fields Values.
__Close
public static final String __Close
__Connection
public static final String __Connection
General Fields.
__ContentEncoding
public static final String __ContentEncoding
Entity Fields.
__ContentLanguage
public static final String __ContentLanguage
Entity Fields.
__ContentLength
public static final String __ContentLength
Entity Fields.
__ContentLocation
public static final String __ContentLocation
Entity Fields.
__ContentMD5
public static final String __ContentMD5
Entity Fields.
__ContentRange
public static final String __ContentRange
Entity Fields.
__ContentType
public static final String __ContentType
Entity Fields.
__Cookie
public static final String __Cookie
Other Fields.
__Date
public static final String __Date
General Fields.
__ETag
public static final String __ETag
Response Fields.
__Expect
public static final String __Expect
Request Fields.
__ExpectContinue
public static final String __ExpectContinue
__Expires
public static final String __Expires
Entity Fields.
__Forwarded
public static final String __Forwarded
Request Fields.
__From
public static final String __From
Request Fields.
__Host
public static final String __Host
Request Fields.
__Identity
public static final String __Identity
Other Fields.
__IfMatch
public static final String __IfMatch
Request Fields.
__IfModifiedSince
public static final String __IfModifiedSince
Request Fields.
__IfNoneMatch
public static final String __IfNoneMatch
Request Fields.
__IfRange
public static final String __IfRange
Request Fields.
__IfUnmodifiedSince
public static final String __IfUnmodifiedSince
Request Fields.
__KeepAlive
public static final String __KeepAlive
Request Fields.
__LastModified
public static final String __LastModified
Entity Fields.
__Location
public static final String __Location
Response Fields.
__MaxForwards
public static final String __MaxForwards
Request Fields.
__MessageHttp
public static final String __MessageHttp
__MimeVersion
public static final String __MimeVersion
Other Fields.
__Pragma
public static final String __Pragma
General Fields.
__ProxyAuthenticate
public static final String __ProxyAuthenticate
Response Fields.
__ProxyAuthorization
public static final String __ProxyAuthorization
Request Fields.
__ProxyConnection
public static final String __ProxyConnection
General Fields.
__Range
public static final String __Range
Request Fields.
__Referer
public static final String __Referer
Request Fields.
__RequestRange
public static final String __RequestRange
Request Fields.
__RetryAfter
public static final String __RetryAfter
Response Fields.
__Server
public static final String __Server
Response Fields.
__ServletEngine
public static final String __ServletEngine
Response Fields.
__SetCookie
public static final String __SetCookie
Other Fields.
__SetCookie2
public static final String __SetCookie2
Other Fields.
__SoapAction
public static final String __SoapAction
Other Fields.
__TE
public static final String __TE
Request Fields.
__TextHtml
public static final String __TextHtml
__Trailer
public static final String __Trailer
General Fields.
__TransferEncoding
public static final String __TransferEncoding
General Fields.
__Upgrade
public static final String __Upgrade
General Fields.
__UserAgent
public static final String __UserAgent
Request Fields.
__Vary
public static final String __Vary
Response Fields.
__Via
public static final String __Via
General Fields.
__Warning
public static final String __Warning
General Fields.
__WwwAuthenticate
public static final String __WwwAuthenticate
Response Fields.
__WwwFormUrlEncode
public static final String __WwwFormUrlEncode
__XForwardedFor
public static final String __XForwardedFor
Request Fields.
__dateCache
public static final DateCache __dateCache
__dateReceiveCache
public static final ThreadLocal __dateReceiveCache
__dateReceiveSource
public static SimpleDateFormat[] __dateReceiveSource
__separators
public static final String __separators
add
public void add(String name,
String value)
throws IllegalArgumentException
Add to or set a field.
If the field is allowed to have multiple values, add will add
multiple headers of the same name.
name
- the name of the fieldvalue
- the value of the field.
add
public void add(HttpFields fields)
Add fields from another HttpFields instance.
Single valued fields are replaced, while all others are added.
addDateField
public void addDateField(String name,
Date date)
Adds the value of a date field.
name
- the field namedate
- the field date value
addDateField
public void addDateField(String name,
long date)
Adds the value of a date field.
name
- the field namedate
- the field date value
addSetCookie
public void addSetCookie(Cookie cookie)
Format a set cookie value
clear
public void clear()
Clear the header.
containsKey
public boolean containsKey(String name)
destroy
public void destroy()
Destroy the header.
Help the garbage collector by null everything that we can.
formatDate
public static String formatDate(Calendar calendar,
boolean cookie)
Format HTTP date
"EEE, dd MMM yyyy HH:mm:ss 'GMT'" or
"EEE, dd-MMM-yy HH:mm:ss 'GMT'"for cookies
formatDate
public static void formatDate(StringBuffer buf,
Calendar calendar,
boolean cookie)
Format HTTP date
"EEE, dd MMM yyyy HH:mm:ss 'GMT'" or
"EEE, dd-MMM-yy HH:mm:ss 'GMT'"for cookies
formatDate
public static String formatDate(StringBuffer buf,
long date,
boolean cookie)
Format HTTP date
"EEE, dd MMM yyyy HH:mm:ss 'GMT'" or
"EEE, dd-MMM-yy HH:mm:ss 'GMT'"for cookies
formatDate
public static String formatDate(long date,
boolean cookie)
Format HTTP date
"EEE, dd MMM yyyy HH:mm:ss 'GMT'" or
"EEE, dd-MMM-yy HH:mm:ss 'GMT'"for cookies
get
public String get(String name)
name
- the case-insensitive field name
- the value of a field, or null if not found. For
multiple fields of the same name, only the first is returned.
getDateField
public long getDateField(String name)
Get a header as a date value.
Returns the value of a date field, or -1 if not found.
The case of the field name is ignored.
name
- the case-insensitive field name
getFieldNames
public Enumeration getFieldNames()
Get enumeration of header _names.
Returns an enumeration of strings representing the header _names
for this request.
getIntField
public int getIntField(String name)
throws NumberFormatException
Get a header as an integer value.
Returns the value of an integer field or -1 if not found.
The case of the field name is ignored.
name
- the case-insensitive field name
getQuality
public static Float getQuality(String value)
getValues
public Enumeration getValues(String name)
Get multi headers
name
- the case-insensitive field name
- Enumeration of the values, or null if no such header.
getValues
public Enumeration getValues(String name,
String separators)
Get multi field values with separator.
The multiple values can be represented as separate headers of
the same name, or by a single header using the separator(s), or
a combination of both. Separators may be quoted.
name
- the case-insensitive field nameseparators
- String of separators.
- Enumeration of the values, or null if no such header.
iterator
public Iterator iterator()
return an iterator for field name:value pairs
put
public void put(String name,
List list)
Set a field.
name
- the name of the fieldlist
- the List value of the field. If null the field is cleared.
put
public String put(String name,
String value)
Set a field.
name
- the name of the fieldvalue
- the value of the field. If null the field is cleared.
putDateField
public void putDateField(String name,
Date date)
Sets the value of a date field.
name
- the field namedate
- the field date value
putDateField
public void putDateField(String name,
long date)
Sets the value of a date field.
name
- the field namedate
- the field date value
putIntField
public void putIntField(String name,
int value)
Sets the value of an integer field.
name
- the field namevalue
- the field integer value
qualityList
public static List qualityList(Enumeration enm)
List values in quality order.
enm
- Enumeration of values with quality parameters
read
public void read(LineInput in)
throws IOException
Read HttpHeaders from inputStream.
remove
public String remove(String name)
Remove a field.
toString
public String toString()
valueParameters
public static String valueParameters(String value,
Map parameters)
Get field value parameters.
Some field values can have parameters. This method separates
the value from the parameters and optionally populates a
map with the paramters. For example:
FieldName : Value ; param1=val1 ; param2=val2
value
- The Field value, possibly with parameteres.parameters
- A map to populate with the parameters, or null
write
public void write(Writer writer)
throws IOException