public class RequestWrapper extends java.lang.Object implements HttpRequest
SESSION_NAMEANDROID_CONTEXT, HTTP_MESSAGE_CONVERTER, REQUEST_CREATED_SESSION, RESPONSE_PRODUCE_TYPEACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_RANGES, Access_Control_Allow_Credentials, Access_Control_Allow_Headers, Access_Control_Allow_Methods, Access_Control_Allow_Origin, Access_Control_Expose_Headers, Access_Control_Max_Age, Access_Control_Request_Headers, Access_Control_Request_Method, AGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_MD5, CONTENT_RANGE, CONTENT_TYPE, COOKIE, DATE, DAV, DEPTH, DESTINATION, ETAG, EXPECT, EXPIRES, FROM, HOST, IF, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LOCATION, LOCK_TOKEN, MAX_FORWARDS, ORIGIN, OVERWRITE, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, RANGE, REFERER, RETRY_AFTER, SERVER, SET_COOKIE, STATUS_URI, TE, TIMEOUT, TRAILER, TRANSFER_ENCODING, UPGRADE, USER_AGENT, VARY, VIA, WARNING, WWW_AUTHENTICATE| Constructor and Description |
|---|
RequestWrapper(HttpRequest request) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
changeSessionId()
Change the session id of the current session associated with this request and return the new session id, if there
is no session associated with the request, an
IllegalStateException is thrown. |
MediaType |
getAccept()
Returns the preferred
MediaType that the client will accept content in, based on the Accept header. |
java.util.Locale |
getAcceptLanguage()
Returns the preferred
Locale that the client will accept content in, based on the Accept-Language
header. |
java.util.List<java.util.Locale> |
getAcceptLanguages()
Returns a
List of Locale objects indicating, in decreasing order starting with the preferred
Locale, the locales that are acceptable to the client based on the Accept-Language header. |
java.util.List<MediaType> |
getAccepts()
Returns a
List of MediaType objects indicating, in decreasing order starting with the preferred
MediaType, the media types that are acceptable to the client based on the Accept header. |
java.lang.Object |
getAttribute(java.lang.String id)
Obtains attribute with the given name.
|
RequestBody |
getBody()
Get the response body.
|
long |
getContentLength()
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is
not known.
|
MediaType |
getContentType()
Returns the MIME type of the body of the request, or
null if the type is not known. |
HttpContext |
getContext()
Get the http context of this request.
|
Cookie |
getCookie(java.lang.String name)
Return a
Cookie object, if there is no cookie corresponding to this name, it returns null. |
java.util.List<Cookie> |
getCookies()
Returns an
List containing all of the Cookie objects the client sent with this request. |
java.lang.String |
getCookieValue(java.lang.String name)
Gets the value of the cookie with the specified name.
|
long |
getDateHeader(java.lang.String name)
Returns the value of the specified request header as a
long value that represents a Date object. |
java.lang.String |
getHeader(java.lang.String name)
Returns the value of the specified request header as a
String. |
java.util.List<java.lang.String> |
getHeaderNames()
Returns an
List of all the header names this request contains, or empty List if the request has
no headers. |
java.util.List<java.lang.String> |
getHeaders(java.lang.String name)
Returns all the values of the specified request header as an
List of String. |
int |
getIntHeader(java.lang.String name)
Returns the value of the specified request header as an
int. |
java.lang.String |
getLocalAddr()
The default behavior of this method is to return getLocalAddr() on the wrapped request object.
|
java.lang.String |
getLocalName()
Returns the host name of the Internet Protocol (IP) interface on which the request was received.
|
int |
getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received.
|
HttpMethod |
getMethod()
Returns
HttpMethod with which this request was made. |
MultiValueMap<java.lang.String,java.lang.String> |
getParameter()
Returns
MultiValueMap of the parameters of this request, or empty MultiValueMap if there are no
parameters. |
java.lang.String |
getParameter(java.lang.String name)
Returns the value of a request parameter as a
String, or null if the parameter does not exist. |
java.util.List<java.lang.String> |
getParameterNames()
Returns an
List of String containing the names of the parameters contained in this request. |
java.util.List<java.lang.String> |
getParameters(java.lang.String name)
Returns an array of
String objects containing all of the values the given request parameter has, or
null if the parameter does not exist. |
java.lang.String |
getPath()
Get the path to this request.
|
java.util.List<java.lang.String> |
getQueries(java.lang.String name)
Returns an
List of String objects containing all of the values the given query parameter name, or
empty List if the query parameter does not exist. |
MultiValueMap<java.lang.String,java.lang.String> |
getQuery()
Returns
MultiValueMap of the query parameters of this request, or empty MultiValueMap if there
are no query parameters. |
java.lang.String |
getQuery(java.lang.String name)
Returns the value of a request parameter as a
String object, or null if the parameter does not
exist. |
java.util.List<java.lang.String> |
getQueryNames()
Returns an
List of String objects containing the names of the query parameters contained in url
of this request, or empty List if there are no query parameters. |
java.lang.String |
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
|
java.lang.String |
getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request.
|
int |
getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
|
HttpRequest |
getRequest()
Get the original request object.
|
RequestDispatcher |
getRequestDispatcher(java.lang.String path)
Returns a
RequestDispatcher object that acts as a wrapper for the resource located at the given path. |
Session |
getSession()
Returns the current session associated with this request, or if the request does not have a session, creates one.
|
java.lang.String |
getURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the
HTTP request.
|
Session |
getValidSession()
Returns the current
Session associated with this request or, if there is no current session returns a new
session. |
boolean |
isSessionValid()
Checks whether the requested session ID is still valid.
|
java.lang.Object |
removeAttribute(java.lang.String id)
Removes attribute with the given name from the context.
|
void |
setAttribute(java.lang.String id,
java.lang.Object obj)
Sets value of the attribute with the given name.
|
public RequestWrapper(HttpRequest request)
public HttpRequest getRequest()
HttpRequest.public java.lang.String getLocalName()
HttpRequestgetLocalName in interface HttpRequestString containing the host name of the IP on which the request was received.public java.lang.String getLocalAddr()
HttpRequestgetLocalAddr in interface HttpRequestpublic int getLocalPort()
HttpRequestgetLocalPort in interface HttpRequestpublic java.lang.String getRemoteAddr()
HttpRequestREMOTE_ADDR.getRemoteAddr in interface HttpRequestString containing the IP address of the client that sent the requestpublic java.lang.String getRemoteHost()
HttpRequestREMOTE_HOST.getRemoteHost in interface HttpRequestString containing the fully qualified name of the clientpublic int getRemotePort()
HttpRequestgetRemotePort in interface HttpRequestpublic HttpMethod getMethod()
HttpRequestHttpMethod with which this request was made.getMethod in interface HttpRequestpublic java.lang.String getURI()
HttpRequestE.g.
| First line of HTTP request | Returned Value | |
|---|---|---|
| POST /some/path.html HTTP/1.1 | /some/path.html | |
| GET http://foo.bar/a.html HTTP/1.0 | /a.html | |
| HEAD /xyz?a=b HTTP/1.1 | /xyz |
getURI in interface HttpRequestpublic java.lang.String getPath()
HttpRequestgetPath in interface HttpRequestpublic java.util.List<java.lang.String> getQueryNames()
HttpRequestList of String objects containing the names of the query parameters contained in url
of this request, or empty List if there are no query parameters.getQueryNames in interface HttpRequestList of String.public java.lang.String getQuery(java.lang.String name)
HttpRequestString object, or null if the parameter does not
exist.
You should only use this method when you are sure the query parameter has only one value. If the query
parameter might have more than one value, use HttpRequest.getQueries(String).
getQuery in interface HttpRequestname - a String specifying the name of the query parameter.HttpRequest.getQueries(String)public java.util.List<java.lang.String> getQueries(java.lang.String name)
HttpRequestList of String objects containing all of the values the given query parameter name, or
empty List if the query parameter does not exist.getQueries in interface HttpRequestname - the name of the query parameter.List of String containing the parameter's values.HttpRequest.getQuery(String)public MultiValueMap<java.lang.String,java.lang.String> getQuery()
HttpRequestMultiValueMap of the query parameters of this request, or empty MultiValueMap if there
are no query parameters.getQuery in interface HttpRequestMultiValueMap containing query parameter names as keys and query parameter values as map values.public java.util.List<java.lang.String> getHeaderNames()
HttpRequestList of all the header names this request contains, or empty List if the request has
no headers.getHeaderNames in interface HttpRequestpublic java.lang.String getHeader(java.lang.String name)
HttpRequestString. If the request did not include a header of
the specified name, this method returns null. If there are multiple headers with the same name, this
method returns the first head in the request.getHeader in interface HttpRequestname - a String specifying the header name.HttpRequest.getHeaders(String)public java.util.List<java.lang.String> getHeaders(java.lang.String name)
HttpRequestList of String.
Some headers, such as Accept-Language can be sent by clients as several headers each with a different
value rather than sending the header as a comma separated list.
If the request did not include any headers of the specified name, this method returns an empty List.
getHeaders in interface HttpRequestname - a String specifying the header name.public long getDateHeader(java.lang.String name)
HttpRequestlong value that represents a Date object.
Use this method with headers that contain dates, e.g. If-Modified-Since.
The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.
If the request did not have a header of the specified name, this method returns -1. If the header can't be
converted to a date, the method throws an IllegalStateException.
getDateHeader in interface HttpRequestname - a String specifying the name of the header.public int getIntHeader(java.lang.String name)
HttpRequestint. If the request does not have a header of the
specified name, this method returns -1. If the header cannot be converted to an integer, this method throws a
IllegalStateException.getIntHeader in interface HttpRequestname - a String specifying the name of a request header.public MediaType getAccept()
HttpRequestMediaType that the client will accept content in, based on the Accept header.getAccept in interface HttpRequestpublic java.util.List<MediaType> getAccepts()
HttpRequestList of MediaType objects indicating, in decreasing order starting with the preferred
MediaType, the media types that are acceptable to the client based on the Accept header. If the client
request doesn't provide an Accept header, this method returns a empty List.getAccepts in interface HttpRequestList of MediaType objects indicating.public java.util.Locale getAcceptLanguage()
HttpRequestLocale that the client will accept content in, based on the Accept-Language
header. If the client request doesn't provide an Accept-Language header, this method returns the default
locale for the server.getAcceptLanguage in interface HttpRequestLocale for the client.public java.util.List<java.util.Locale> getAcceptLanguages()
HttpRequestList of Locale objects indicating, in decreasing order starting with the preferred
Locale, the locales that are acceptable to the client based on the Accept-Language header. If the
client request doesn't provide an Accept-Language header, this method returns a List containing
one Locale, the default locale for the server.getAcceptLanguages in interface HttpRequestList of preferred Locale objects for the client.public java.lang.String getCookieValue(java.lang.String name)
HttpRequestgetCookieValue in interface HttpRequestname - the name of value.public Cookie getCookie(java.lang.String name)
HttpRequestCookie object, if there is no cookie corresponding to this name, it returns null.getCookie in interface HttpRequestname - cookie name.Cookie object or null if there is no cookie corresponding to this name .public java.util.List<Cookie> getCookies()
HttpRequestList containing all of the Cookie objects the client sent with this request. This
method returns null if no cookies were sent.getCookies in interface HttpRequestpublic long getContentLength()
HttpRequestgetContentLength in interface HttpRequestpublic MediaType getContentType()
HttpRequestnull if the type is not known.getContentType in interface HttpRequestString containing the name of the MIME type of the request, or null if the type is not known.public java.util.List<java.lang.String> getParameterNames()
HttpRequestList of String containing the names of the parameters contained in this request. If
the request has no parameters, the method returns an empty List.getParameterNames in interface HttpRequestList of String objects.public java.lang.String getParameter(java.lang.String name)
HttpRequestString, or null if the parameter does not exist.
You should only use this method when you are sure the parameter has only one value. If the parameter might
have more than one value, use HttpRequest.getParameters(String).
getParameter in interface HttpRequestname - a String specifying the name of the parameter.HttpRequest.getParameters(String)public java.util.List<java.lang.String> getParameters(java.lang.String name)
HttpRequestString objects containing all of the values the given request parameter has, or
null if the parameter does not exist.getParameters in interface HttpRequestname - a String containing the name of the parameter whose value is requested.String objects containing the parameter's values.HttpRequest.getParameter(String)public MultiValueMap<java.lang.String,java.lang.String> getParameter()
HttpRequestMultiValueMap of the parameters of this request, or empty MultiValueMap if there are no
parameters.getParameter in interface HttpRequestMultiValueMap containing parameter names as keys and parameter values as map values.public RequestBody getBody() throws java.lang.UnsupportedOperationException
HttpRequestgetBody in interface HttpRequestRequestBody.java.lang.UnsupportedOperationException - if the request method does not allow the body to be sent.public Session getValidSession()
HttpRequestSession associated with this request or, if there is no current session returns a new
session.getValidSession in interface HttpRequestHttpRequest.getSession()public Session getSession()
HttpRequestgetSession in interface HttpRequestHttpRequest.getValidSession()public java.lang.String changeSessionId()
HttpRequestIllegalStateException is thrown.changeSessionId in interface HttpRequestHttpRequest.getSession(),
HttpRequest.getValidSession()public boolean isSessionValid()
HttpRequestIf the client did not specify any session ID, this method returns false.
isSessionValid in interface HttpRequestHttpRequest.getSession(),
HttpRequest.getValidSession()public RequestDispatcher getRequestDispatcher(java.lang.String path)
HttpRequestRequestDispatcher object that acts as a wrapper for the resource located at the given path.getRequestDispatcher in interface HttpRequestRequestDispatcher object or null if the handler corresponding to the path is not
found.public HttpContext getContext()
HttpRequestgetContext in interface HttpRequestHttpContext.public java.lang.Object getAttribute(java.lang.String id)
HttpContextgetAttribute in interface HttpContextid - the attribute name.null if not set.public void setAttribute(java.lang.String id,
java.lang.Object obj)
HttpContextsetAttribute in interface HttpContextid - the attribute name.obj - the attribute value.public java.lang.Object removeAttribute(java.lang.String id)
HttpContextremoveAttribute in interface HttpContextid - the attribute name.null if not set.