public interface RequestHeader extends RequestLine
Header
object that is used to represent a
basic form for the HTTP request message. This is used to extract
values such as the request line and header values from the request
message. Access to header values is done case insensitively.
As well as providing the header values and request line values this will also provide convenience methods which enable the user to determine the length of the body this message header prefixes.
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.String name)
This is used to see if there is a HTTP message header with the
given name in this container.
|
int |
getContentLength()
This is a convenience method that can be used to determine
the length of the message body.
|
ContentType |
getContentType()
This is a convenience method that can be used to determine the
content type of the message body.
|
Cookie |
getCookie(java.lang.String name)
This is used to acquire a cookie using the name of that cookie.
|
java.util.List<Cookie> |
getCookies()
This is used to acquire all cookies that were sent in the header.
|
long |
getDate(java.lang.String name)
This can be used to get the date of the first message header
that has the specified name.
|
int |
getInteger(java.lang.String name)
This can be used to get the integer of the first message header
that has the specified name.
|
java.util.List<java.util.Locale> |
getLocales()
This is used to acquire the locales from the request header.
|
java.util.List<java.lang.String> |
getNames()
This method is used to get a
List of the names
for the headers. |
java.lang.String |
getValue(java.lang.String name)
This can be used to get the value of the first message header
that has the specified name.
|
java.util.List<java.lang.String> |
getValues(java.lang.String name)
This can be used to get the values of HTTP message headers
that have the specified name.
|
getAddress, getMajor, getMethod, getMinor, getPath, getQuery, getTarget
java.util.List<java.lang.String> getNames()
List
of the names
for the headers. This will provide the original names for the
HTTP headers for the message. Modifications to the provided
list will not affect the header, the list is a simple copy.int getInteger(java.lang.String name)
name
- the HTTP message header to get the value fromlong getDate(java.lang.String name)
name
- the HTTP message header to get the value fromCookie getCookie(java.lang.String name)
Cookie
object. Otherwise this method will
return null. Each cookie object will contain the name, value
and path of the cookie as well as the optional domain part.name
- this is the name of the cookie object to acquirejava.util.List<Cookie> getCookies()
Cookie
objects. Otherwise this method will an
empty list. Each cookie object will contain the name, value and
path of the cookie as well as the optional domain part.java.lang.String getValue(java.lang.String name)
name
- the HTTP message header to get the value fromjava.util.List<java.lang.String> getValues(java.lang.String name)
substring
and trim
calls.
The tokens returned by this method are ordered according to there HTTP quality values, or "q" values, see RFC 2616 section 3.9. This also strips out the quality parameter from tokens returned. So "image/html; q=0.9" results in "image/html". If there are no "q" values present then order is by appearance.
The result from this is either the trimmed header value, that is, the header value with no leading or trailing whitespace or an array of trimmed tokens ordered with the most preferred in the lower indexes, so index 0 is has highest preference.
name
- the name of the headers that are to be retrievedjava.util.List<java.util.Locale> getLocales()
Accept-Language
header.
This provides an indication as to the languages that the client
accepts. It provides the locales in preference order.boolean contains(java.lang.String name)
name
- the HTTP message header to get the value fromContentType getContentType()
Content-Type
header, if there is then
this will parse that header and represent it as a typed object
which will expose the various parts of the HTTP header.int getContentLength()
Content-Length
header, if it does then the
length can be determined, if not then this returns -1.