public class HttpRequest
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static int |
AFTER |
protected static int |
AFTER_ALL |
protected static int |
BEFORE |
protected static int |
BEFORE_ALL
method to mark filters
|
static int |
CONNECT
Value returned by
getMethod() if the request method is CONNECT . |
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 |
HEAD
Value returned by
getMethod() if the request method is HEAD . |
static int |
OPTIONS
Value returned by
getMethod() if the request method is OPTIONS . |
static int |
PATCH
Value returned by
getMethod() if the request method is PATCH . |
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 . |
static int |
TRACE
Value returned by
getMethod() if the request method is TRACE . |
Modifier | Constructor and Description |
---|---|
protected |
HttpRequest(java.io.InputStream inputStream,
EncodingRegistry encodingRegistry)
Constructs a new instance of HTTPRequest.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addPathParameters(java.util.Map<java.lang.String,java.lang.String> parameters) |
protected void |
addSplatParameters(java.util.List<java.lang.String> splatParameters)
Sets the splat Parameters.
|
java.lang.Object |
getAttribute(java.lang.String key)
Get request server-side attribute by key
|
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.lang.String |
getHeader(java.lang.String name)
Returns the header field value associated to the given header field
name . |
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Returns all HTTP header fields of the request.
|
int |
getMethod()
|
java.lang.String |
getPathParam(java.lang.String param) |
java.lang.String |
getQueryParam(java.lang.String name)
Returns the a Query parameter
|
java.util.Map<java.lang.String,java.lang.String> |
getQueryParams()
Returns the Query parameters as
Map . |
java.io.InputStream |
getRequestBody()
use
parseBody(BodyParser) for more option on request body provided parsers. |
java.util.List<java.lang.String> |
getSplatParams() |
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.
|
void |
setAttribute(java.lang.String key,
java.lang.Object value)
set a request server-side attribute
|
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
.public static final int HEAD
getMethod()
if the request method is HEAD
.public static final int CONNECT
getMethod()
if the request method is CONNECT
.public static final int OPTIONS
getMethod()
if the request method is OPTIONS
.public static final int TRACE
getMethod()
if the request method is TRACE
.public static final int PATCH
getMethod()
if the request method is PATCH
.protected static final int BEFORE_ALL
protected static final int BEFORE
protected static final int AFTER
protected static final int AFTER_ALL
protected HttpRequest(java.io.InputStream inputStream, EncodingRegistry 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> getQueryParams()
Map
.Map
of (String,String) representing the HTTP query parameters.public java.lang.String getQueryParam(java.lang.String name)
name
- of query parameterpublic java.lang.String getPathParam(java.lang.String param)
param
- path parameter namepublic java.util.List<java.lang.String> getSplatParams()
List
of splat parameters list.protected void addSplatParameters(java.util.List<java.lang.String> splatParameters)
splatParameters
- the splat parameters to set.protected void addPathParameters(java.util.Map<java.lang.String,java.lang.String> parameters)
parameters
- path parameters to be added to the requestpublic java.lang.Object getAttribute(java.lang.String key)
key
- attribute keypublic void setAttribute(java.lang.String key, java.lang.Object value)
key
- attribute keyvalue
- attribute valuepublic java.lang.String getVersion()
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
Map
of (String,String) representing the HTTP header fields (may be empty).public java.lang.String getHeader(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.public java.io.InputStream getRequestBody()
parseBody(BodyParser)
for more option on request body provided parsers.