public interface IRequestRequestContextAddon<R extends IRequestContext<?>>
request.| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBodyAsByteArray()
The bytes of the request's body.
|
InputStream |
getBodyAsInputStream()
The raw InputStream of the request's body.
|
String |
getBodyAsString()
The request's body as a String, using the
UTF-8 encoding. |
String |
getBodyAsString(String encoding)
The request's body as a String, using the specified encoding.
|
String |
getContentType()
The Content-Type of the request, if any.
|
ContentTypeDefaults |
getContentTypeBestMatch()
Finds the best
Content-Type to use for a response
using the "Accept" header of the request. |
Date |
getDateFromIfModifiedSinceHeader()
Return the value of the
If-Modified-Since
header as a Date or null if it doesn't
exist. |
Date |
getDateFromIfUnmodifiedSinceHeader()
Return the value of the
If-Unmodified-Since
header as a Date or null if it doesn't
exist. |
List<IETag> |
getEtagsFromIfMatchHeader()
Returns the
ETags from
the If-Match header, if any. |
List<IETag> |
getEtagsFromIfNoneMatchHeader()
Returns the
ETags from
the If-None-Match header, if any. |
List<String> |
getFormData(String name)
A specific parameter submitted from a
FORM via a POST method. |
String |
getFormDataFirst(String name)
The first (and often only) value of a specific parameter submitted from a
FORM via a POST method. |
IJsonObject |
getFormDatas()
The datas submitted from a
FORM via a POST method. |
Map<String,List<String>> |
getFormDatasAsMap()
The datas submitted from a
FORM via a POST method, as
a Map. |
String |
getFullUrl()
Returns the current full URL, including the queryString, if any.
|
String |
getFullUrl(boolean keepCacheBusters)
Returns the current full URL, including the queryString, if any.
|
String |
getFullUrlOriginal()
If the request has been forwarded, this is going to return the original
URL, not the current, forwarded, one.
|
String |
getFullUrlOriginal(boolean keepCacheBusters)
If the request has been forwarded, this is going to return the original
URL, not the current, forwarded, one.
|
String |
getFullUrlProxied()
If a reverse proxy has been used, this URL will contain the
scheme, host and port
as forwarded by the reserve proxy, not as seen by the user. |
String |
getFullUrlProxied(boolean keepCacheBusters)
If a reverse proxy has been used, this URL will contain the
scheme, host and port
as forwarded by the reserve proxy, not as seen by the user. |
List<String> |
getHeader(String name)
Returns the values of the specified header from the current request or
an empty list if not found.
|
String |
getHeaderFirst(String name)
The first value of the specified header from the current request.
|
Map<String,List<String>> |
getHeaders()
Returns all headers of the current request.
|
HttpMethod |
getHttpMethod()
Gets the request's
HTTP method. |
<T> T |
getJsonBody(Class<T> clazz)
The request's body deserialized to the specified
class. |
IJsonObject |
getJsonBodyAsJsonObject()
The request's body deserialized to a
IJsonObject. |
Map<String,Object> |
getJsonBodyAsMap()
The request's body deserialized to a
Map<String, Object>. |
Locale |
getLocaleBestMatch()
Find the best
Locale to use for a response
using the "Accept-Language" header of
the request. |
String |
getPathParam(String name)
A specific value parsed from a dynamic parameter of the route path.
|
Map<String,String> |
getPathParams()
The values parsed from the dynamic parameters of the route path.
|
String |
getQueryString(boolean withQuestionMark)
The queryString of the request.
|
List<String> |
getQueryStringParam(String name)
A specific parameter taken from the queryString of the request.
|
String |
getQueryStringParamFirst(String name)
The first (and often only) value of a specific parameter taken from the
queryString of the request.
|
Map<String,List<String>> |
getQueryStringParams()
The parameters taken from the queryString of the request.
|
String |
getRequestPath()
The path of the request (no querystring).
|
String |
getRequestPath(boolean keepCacheBusters)
The path of the request (no querystring).
|
File |
getUploadedFileFirst(String name)
The first (and often only) uploaded file of the specified name.
|
Map<String,List<File>> |
getUploadedFiles()
The uploaded files, with their names as the keys.
|
List<File> |
getUploadedFiles(String name)
The uploaded files of the specified name.
|
<T> T |
getXmlBody(Class<T> clazz)
The request's body deserialized to the specified
class. |
IJsonObject |
getXmlBodyAsJsonObject()
The request's body deserialized to a
IJsonObject. |
Map<String,Object> |
getXmlBodyAsMap()
The request's body deserialized to a
Map<String, Object>. |
boolean |
isHTMLShouldBeReturn()
Will return
true if the request specifies
that HTML is the most appropriate format
to return. |
boolean |
isHttps()
Is the request a secure HTTPS one?
|
boolean |
isJsonShouldBeReturn()
Will return
true if the request specifies
that Json is the most appropriate format
to return. |
boolean |
isPlainTextShouldBeReturn()
Will return
true if the request specifies
that plain-text is the most appropriate format
to return. |
boolean |
isXMLShouldBeReturn()
Will return
true if the request specifies
that XML is the most appropriate format
to return. |
HttpMethod getHttpMethod()
HTTP method.ContentTypeDefaults getContentTypeBestMatch()
Content-Type to use for a response
using the "Accept" header of the request. It will
fallback to ContentTypeDefaults.TEXT if nothing more specific
is found.boolean isJsonShouldBeReturn()
true if the request specifies
that Json is the most appropriate format
to return.boolean isHTMLShouldBeReturn()
true if the request specifies
that HTML is the most appropriate format
to return.boolean isXMLShouldBeReturn()
true if the request specifies
that XML is the most appropriate format
to return.boolean isPlainTextShouldBeReturn()
true if the request specifies
that plain-text is the most appropriate format
to return.Locale getLocaleBestMatch()
Locale to use for a response
using the "Accept-Language" header of
the request.
Returns the default Locale (taken from the configurations)
if nothing more specific is found.Map<String,List<String>> getHeaders()
TreeMap which iscase insensitive for the keys.
The map is immutable.List<String> getHeader(String name)
name is case insensitive.
The list is immutable.String getHeaderFirst(String name)
name is case insensitive.
Returns null if the header is not found.String getContentType()
Content-Type of the request or null
if none was specified.String getFullUrl()
In case the request has been forwarded, this will be the *new*,
the current URL. Use getFullUrlOriginal()
to get the original URL, before the request was forwarded.
If a reverse proxy has been used, this URL will contain the
scheme, host and port from the
original URL, as seen by the user.
In general, this is what you want to use in your application.
String getFullUrl(boolean keepCacheBusters)
In case the request has been forwarded, this will be the *new*,
the current URL. Use getFullUrlOriginal()
to get the original URL, before the request was forwarded.
If a reverse proxy has been used, this URL will contain the
scheme, host and port from the
original URL, as seen by the user.
In general, this is what you want to use in your application.
keepCacheBusters - if true, the returned URL will contain
the cache buster codes, if there were any. The default behavior is to
automatically remove them.String getFullUrlOriginal()
Use getFullUrl() to get the current, potentially
forwarded URL.
If a reverse proxy has been used, this URL will contain the
scheme, host and port from the
original URL, as seen by the user.
In general, this is what you want to use in your application.
String getFullUrlOriginal(boolean keepCacheBusters)
Use getFullUrl() to get the current, potentially
forwarded URL.
If a reverse proxy has been used, this URL will contain the
scheme, host and port from the
original URL, as seen by the user.
In general, this is what you want to use in your application.
keepCacheBusters - if true, the returned URL will contain
the cache buster codes, if there were any. The default behavior is to
automatically remove them.String getFullUrlProxied()
scheme, host and port
as forwarded by the reserve proxy, not as seen by the user.
Cache buster codes are removed, if there were any.
If the request has been forwarded, this is going to return the original URL, not the current, forwarded, one.
In general, you should probably use getFullUrl()
or getFullUrlOriginal() instead of this
one.
String getFullUrlProxied(boolean keepCacheBusters)
scheme, host and port
as forwarded by the reserve proxy, not as seen by the user.
Cache buster codes are removed, if there were any.
If the request has been forwarded, this is going to return the original URL, not the current, forwarded, one.
In general, you should probably use getFullUrl()
or getFullUrlOriginal() instead of this
one.
keepCacheBusters - if true, the returned URL will contain
the cache buster codes, if there were any. The default behavior is to
automatically remove them.String getRequestPath()
String getRequestPath(boolean keepCacheBusters)
keepCacheBusters - if true, the returned path will contain
the cache buster codes, if there were any. The default behavior is to
automatically remove them.Map<String,String> getPathParams()
String getPathParam(String name)
name is case sensitive, since you have easy control over it.String getQueryString(boolean withQuestionMark)
withQuestionMark - if true and the queryString
is not empty, the result will be prefixed with "?".Map<String,List<String>> getQueryStringParams()
List<String> getQueryStringParam(String name)
String getQueryStringParamFirst(String name)
null if the parameter doesn't exist.InputStream getBodyAsInputStream()
byte[] getBodyAsByteArray()
String getBodyAsString()
UTF-8 encoding.
Note that the characters read cannot be read again!String getBodyAsString(String encoding)
IJsonObject getJsonBodyAsJsonObject()
IJsonObject. A valid Json body
is expected.
Note that this can only be called once.Map<String,Object> getJsonBodyAsMap()
Map<String, Object>. A valid Json body
is expected.
Note that this can only be called once.<T> T getJsonBody(Class<T> clazz)
class. A valid Json body
is expected.
Note that this can only be called once.IJsonObject getXmlBodyAsJsonObject()
IJsonObject. A valid XML body
is expected.
Note that this can only be called once.Map<String,Object> getXmlBodyAsMap()
Map<String, Object>. A valid XML body
is expected.
Note that this can only be called once.<T> T getXmlBody(Class<T> clazz)
class. A valid XML body
is expected.
Note that this can only be called once.Map<String,List<String>> getFormDatasAsMap()
FORM via a POST method, as
a Map.
More than one value with the same key is possible.
The names are case sensitive.
This returns an immutable object! You won't be able to add or remove elements.
IJsonObject getFormDatas()
FORM via a POST method.
More than one value with the same key is possible.
The names are case sensitive.
This returns a new instance of IJsonObject. Any modification
to the object or to one of its IJsonArray property won't affect the
original form datas.
List<String> getFormData(String name)
FORM via a POST method.
More than one value with the same name is possible.
The name is case sensitive.
This returns a new instance of List. Any modification
to the list won't affect the original form datas.
String getFormDataFirst(String name)
FORM via a POST method.
The name is case sensitive.
Returns null if the parameter doesn't exist.Map<String,List<File>> getUploadedFiles()
List<File> getUploadedFiles(String name)
name is possible.
The list is immutable.
Returns an empty list if no uploaded files of this name exists.File getUploadedFileFirst(String name)
null if no uploaded file of this name exists.boolean isHttps()
List<IETag> getEtagsFromIfNoneMatchHeader()
ETags from
the If-None-Match header, if any.If-None-Match ETags or an empty
list if there is none.List<IETag> getEtagsFromIfMatchHeader()
ETags from
the If-Match header, if any.If-Match ETags or an empty list
if there is none.Date getDateFromIfModifiedSinceHeader()
If-Modified-Since
header as a Date or null if it doesn't
exist.Date getDateFromIfUnmodifiedSinceHeader()
If-Unmodified-Since
header as a Date or null if it doesn't
exist.Copyright © 2016. All rights reserved.