Package org.simpleframework.http.message
Interface Header
- All Superinterfaces:
Segment
- All Known Implementing Classes:
HeaderConsumer
,RequestConsumer
This is a
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.
-
Method Summary
Modifier and TypeMethodDescriptionThis is used to acquire the address from the request line.This is used to acquire a cookie usiing the name of that cookie.This is used to acquire all cookies that were sent in the header.long
This can be used to get the date of the first message header that has the specified name.This method returns aCharSequence
holding the data consumed for the request.int
getInteger
(String name) This can be used to get the integer of the first message header that has the specified name.This is used to acquire the locales from the request header.int
getMajor()
This can be used to get the major number from a HTTP version.This can be used to get the HTTP method for this request.int
getMinor()
This can be used to get the minor number from a HTTP version.getNames()
This method is used to get aList
of the names for the headers.getPath()
This is used to acquire the path as extracted from the the HTTP request URI.getQuery()
This method is used to acquire the query part from the HTTP request URI target.This can be used to get the target specified for this HTTP request.boolean
This is used to determine if the header represents one that requires the HTTP/1.1 continue expectation.toString()
This method returns a string representing the header that was consumed by this consumer.Methods inherited from interface org.simpleframework.http.message.Segment
getContentLength, getContentType, getDisposition, getFileName, getName, getTransferEncoding, getValue, getValue, getValues, isFile
-
Method Details
-
getTarget
String getTarget()This can be used to get the target specified for this HTTP request. This corresponds to the URI sent in the request line. Typically this will be the path part of the URI, but can be the full URI if the request is a proxy request.- Returns:
- the target URI that this HTTP request specifies
-
getHeader
CharSequence getHeader()This method returns aCharSequence
holding the data consumed for the request. A character sequence is returned as it can provide a much more efficient means of representing the header data by just wrapping the consumed byte array.- Returns:
- this returns the characters consumed for the header
-
getAddress
Address getAddress()This is used to acquire the address from the request line. An address is the full URI including the scheme, domain, port and the query parts. This allows various parameters to be acquired without having to parse the target.- Returns:
- this returns the address of the request line
-
getPath
Path getPath()This is used to acquire the path as extracted from the the HTTP request URI. ThePath
object that is provided by this method is immutable, it represents the normalized path only part from the request URI.- Returns:
- this returns the normalized path for the request
-
getQuery
Query getQuery()This method is used to acquire the query part from the HTTP request URI target. This will return only the values that have been extracted from the request URI target.- Returns:
- the query associated with the HTTP target URI
-
getMethod
String getMethod()This can be used to get the HTTP method for this request. The HTTP specification RFC 2616 specifies the HTTP request methods in section 9, Method Definitions. Typically this will be a GET or POST method, but can be any valid alphabetic token.- Returns:
- the HTTP method that this request has specified
-
getMajor
int getMajor()This can be used to get the major number from a HTTP version. The major version corresponds to the major protocol type, that is the 1 of a HTTP/1.1 version string. Typically the major type is 1, by can be 0 for HTTP/0.9 clients.- Returns:
- the major version number for the HTTP message
-
getMinor
int getMinor()This can be used to get the minor number from a HTTP version. The minor version corresponds to the minor protocol type, that is the 0 of a HTTP/1.0 version string. This number is typically used to determine whether persistent connections are supported.- Returns:
- the minor version number for the HTTP message
-
getNames
This method is used to get aList
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.- Returns:
- this returns a list of the names within the header
-
getInteger
This can be used to get the integer of the first message header that has the specified name. This is a convenience method that avoids having to deal with parsing the value of the requested HTTP message header. This returns -1 if theres no HTTP header value for the specified name.- Parameters:
name
- the HTTP message header to get the value from- Returns:
- this returns the date as a long from the header value
-
getDate
This can be used to get the date of the first message header that has the specified name. This is a convenience method that avoids having to deal with parsing the value of the requested HTTP message header. This returns -1 if theres no HTTP header value for the specified name.- Parameters:
name
- the HTTP message header to get the value from- Returns:
- this returns the date as a long from the header value
-
getCookie
This is used to acquire a cookie usiing the name of that cookie. If the cookie exists within the HTTP header then it is returned as aCookie
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.- Parameters:
name
- this is the name of the cookie object to acquire- Returns:
- this returns a cookie object from the header or null
-
getCookies
This is used to acquire all cookies that were sent in the header. If any cookies exists within the HTTP header they are returned asCookie
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.- Returns:
- this returns all cookie objects from the HTTP header
-
getLocales
This is used to acquire the locales from the request header. The locales are provided in theAccept-Language
header. This provides an indication as to the languages that the client accepts. It provides the locales in preference order.- Returns:
- this returns the locales preferred by the client
-
isExpectContinue
boolean isExpectContinue()This is used to determine if the header represents one that requires the HTTP/1.1 continue expectation. If the request does require this expectation then it should be send the 100 status code which prompts delivery of the message body.- Returns:
- this returns true if a continue expectation exists
-
toString
String toString()This method returns a string representing the header that was consumed by this consumer. For performance reasons it is better to acquire the character sequence representing the header as it does not require the allocation on new memory.
-