public class HTTPRequest
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DELETE
Value returned by
getMethod() if the request method is DELETE . |
static int |
GET
Value returned by
getMethod() if the request method is GET . |
static int |
POST
Value returned by
getMethod() if the request method is POST . |
static int |
PUT
Value returned by
getMethod() if the request method is PUT . |
Modifier | Constructor and Description |
---|---|
protected |
HTTPRequest(java.io.InputStream inputStream,
HTTPEncodingRegistry encodingRegistry)
Constructs a new instance of HTTPRequest.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCookie(java.lang.String name)
Return the cookie of the request with given name.
|
java.util.Map<java.lang.String,java.lang.String> |
getCookies()
Returns the cookies of the request.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeader()
Returns all HTTP header fields of the request.
|
java.lang.String |
getHeaderField(java.lang.String name)
Returns the header field value associated to the given header field
name . |
int |
getMethod()
|
java.util.Map<java.lang.String,java.lang.String> |
getParameters()
Returns the query parameters as
Map . |
java.lang.String |
getURI()
Returns the request URI.
|
java.lang.String |
getVersion()
Returns the HTTP version request.
|
<T> T |
parseBody(BodyParser<T> bodyParser)
Request the body to be parsed.
|
public static final int POST
getMethod()
if the request method is POST
.public static final int GET
getMethod()
if the request method is GET
.public static final int PUT
getMethod()
if the request method is PUT
.public static final int DELETE
getMethod()
if the request method is DELETE
.protected HTTPRequest(java.io.InputStream inputStream, HTTPEncodingRegistry encodingRegistry) throws java.io.IOException
inputStream
- the input stream of the request.encodingRegistry
- the register of available encoding and transfer coding handlers.java.io.IOException
- if connection is lost during processing the request.java.lang.IllegalArgumentException
- if parsing the request failed.public java.lang.String getURI()
public java.util.Map<java.lang.String,java.lang.String> getParameters()
Map
.Map
of (String,String) representing the HTTP query parameters.public java.lang.String getVersion()
public java.util.Map<java.lang.String,java.lang.String> getHeader()
Map
of (String,String) representing the HTTP header fields (may be empty).public java.lang.String getHeaderField(java.lang.String name)
name
.name
- the header field name.null
if the header field is not found or name
is null.public java.util.Map<java.lang.String,java.lang.String> getCookies()
Cookies are lazily parsed.
Map
of (String,String) representing the HTTP cookies (may be empty)public java.lang.String getCookie(java.lang.String name)
Cookies are lazily parsed.
name
- the name of the cookie.null
if name
is null
.public <T> T parseBody(BodyParser<T> bodyParser) throws java.io.IOException
T
- the type of body.bodyParser
- the parser.java.io.IOException
- if an IOException
occurs during parsing.