public class RequestConsumer extends HeaderConsumer
RequestConsumer
object is used to parse the HTTP
request line followed by the HTTP message headers. This parses the
request URI such that the query parameters and path are extracted
and normalized. It performs this using external parsers, which
will remove and escaped characters and normalize the path segments.
Finally this exposes the HTTP version used using the major and
minor numbers sent with the HTTP request.Modifier and Type | Field and Description |
---|---|
protected int |
major
This is the major version number of the HTTP request header.
|
protected String |
method
This is the method token send with the HTTP request header.
|
protected int |
minor
This is the minor version number of the HTTP request header.
|
protected AddressParser |
parser
This is the address parser used to parse the request URI.
|
protected String |
target
This represents the raw request URI in an unparsed form.
|
cookies, disposition, encoding, expect, header, language, length, limit, name, pos, scan, type, value
array, chunk, count, done
Constructor and Description |
---|
RequestConsumer()
Constructor for the
RequestConsumer object. |
Modifier and Type | Method and Description |
---|---|
protected boolean |
digit(byte octet)
This is used to determine if a given ISO-8859-1 byte is a digit
character, between an ISO-8859-1 0 and 9.
|
Address |
getAddress()
This is used to acquire the address from the request line.
|
long |
getDate(String name)
This can be used to get the date of the first message header
that has the specified name.
|
CharSequence |
getHeader()
This method returns a
CharSequence 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.
|
int |
getMajor()
This can be used to get the major number from a HTTP version.
|
String |
getMethod()
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.
|
List<String> |
getNames()
This method is used to get a
List of the names
for the headers. |
Path |
getPath()
This is used to acquire the path as extracted from the
the HTTP request URI.
|
Query |
getQuery()
This method is used to acquire the query part from the
HTTP request URI target.
|
String |
getTarget()
This can be used to get the target specified for this HTTP
request.
|
protected void |
process()
This method is invoked after the terminal token has been read.
|
String |
toString()
This is used to convert the byte range to a string.
|
protected void |
version()
This will parse HTTP version from the first line of the header
and store the parsed string internally.
|
getCookie, getCookies
add, adjust, cookie, disposition, encoding, end, equal, expect, getContentLength, getContentType, getDisposition, getFileName, getLocales, getName, getTransferEncoding, getValue, getValue, getValues, headers, isExpectContinue, isFile, language, length, resize, scan, space, terminal, type, white
consume, isFinished
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getLocales, isExpectContinue
getContentLength, getContentType, getDisposition, getFileName, getName, getTransferEncoding, getValue, getValue, getValues, isFile
protected AddressParser parser
protected String method
protected String target
protected int major
protected int minor
public RequestConsumer()
RequestConsumer
object. This
is used to create a consumer which can consume a HTTP request
header and provide the consumed contents via a known interface.
This also further breaks down the request URI for convenience.public String getTarget()
public Address getAddress()
public Query getQuery()
public Path getPath()
Path
object that is
provided by this method is immutable, it represents the
normalized path only part from the request URI.public String getMethod()
public int getMajor()
public int getMinor()
public long getDate(String name)
getDate
in interface Header
getDate
in class HeaderConsumer
name
- the HTTP message header to get the value frompublic int getInteger(String name)
getInteger
in interface Header
getInteger
in class HeaderConsumer
name
- the HTTP message header to get the value frompublic List<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.getNames
in interface Header
getNames
in class HeaderConsumer
protected void process()
process
in class SegmentConsumer
protected void version()
protected boolean digit(byte octet)
octet
- this is to be checked to see if it is a digitpublic CharSequence getHeader()
CharSequence
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.public String toString()
toString
in interface Header
toString
in class SegmentConsumer
Copyright © 2016. All rights reserved.