public interface HttpRequest extends HttpContext, HttpHeaders
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
SESSION_NAME |
ANDROID_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| 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. |
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.
|
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.
|
getAttribute, removeAttribute, setAttributestatic final java.lang.String SESSION_NAME
java.lang.String getLocalName()
String containing the host name of the IP on which the request was received.java.lang.String getLocalAddr()
int getLocalPort()
java.lang.String getRemoteAddr()
REMOTE_ADDR.String containing the IP address of the client that sent the requestjava.lang.String getRemoteHost()
REMOTE_HOST.String containing the fully qualified name of the clientint getRemotePort()
HttpMethod getMethod()
HttpMethod with which this request was made.java.lang.String getURI()
E.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 |
java.lang.String getPath()
java.util.List<java.lang.String> getQueryNames()
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.List of String.java.lang.String getQuery(java.lang.String name)
String 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 getQueries(String).
name - a String specifying the name of the query parameter.getQueries(String)java.util.List<java.lang.String> getQueries(java.lang.String name)
List of String objects containing all of the values the given query parameter name, or
empty List if the query parameter does not exist.name - the name of the query parameter.List of String containing the parameter's values.getQuery(String)MultiValueMap<java.lang.String,java.lang.String> getQuery()
MultiValueMap of the query parameters of this request, or empty MultiValueMap if there
are no query parameters.MultiValueMap containing query parameter names as keys and query parameter values as map values.java.util.List<java.lang.String> getHeaderNames()
List of all the header names this request contains, or empty List if the request has
no headers.java.lang.String getHeader(java.lang.String name)
String. 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.name - a String specifying the header name.getHeaders(String)java.util.List<java.lang.String> getHeaders(java.lang.String name)
List 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.
name - a String specifying the header name.long getDateHeader(java.lang.String name)
long 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.
name - a String specifying the name of the header.int getIntHeader(java.lang.String name)
int. 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.name - a String specifying the name of a request header.MediaType getAccept()
MediaType that the client will accept content in, based on the Accept header.java.util.List<MediaType> getAccepts()
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. If the client
request doesn't provide an Accept header, this method returns a empty List.List of MediaType objects indicating.java.util.Locale getAcceptLanguage()
Locale 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.Locale for the client.java.util.List<java.util.Locale> getAcceptLanguages()
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. 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.List of preferred Locale objects for the client.java.lang.String getCookieValue(java.lang.String name)
name - the name of value.Cookie getCookie(java.lang.String name)
Cookie object, if there is no cookie corresponding to this name, it returns null.name - cookie name.Cookie object or null if there is no cookie corresponding to this name .java.util.List<Cookie> getCookies()
List containing all of the Cookie objects the client sent with this request. This
method returns null if no cookies were sent.long getContentLength()
MediaType getContentType()
null if the type is not known.String containing the name of the MIME type of the request, or null if the type is not known.java.util.List<java.lang.String> getParameterNames()
List of String containing the names of the parameters contained in this request. If
the request has no parameters, the method returns an empty List.List of String objects.java.lang.String getParameter(java.lang.String name)
String, 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 getParameters(String).
name - a String specifying the name of the parameter.getParameters(String)java.util.List<java.lang.String> getParameters(java.lang.String name)
String objects containing all of the values the given request parameter has, or
null if the parameter does not exist.name - a String containing the name of the parameter whose value is requested.String objects containing the parameter's values.getParameter(String)MultiValueMap<java.lang.String,java.lang.String> getParameter()
MultiValueMap of the parameters of this request, or empty MultiValueMap if there are no
parameters.MultiValueMap containing parameter names as keys and parameter values as map values.RequestBody getBody()
RequestBody.java.lang.UnsupportedOperationException - if the request method does not allow the body to be sent.Session getValidSession()
Session associated with this request or, if there is no current session returns a new
session.getSession()Session getSession()
getValidSession()java.lang.String changeSessionId()
IllegalStateException is thrown.getSession(),
getValidSession()boolean isSessionValid()
If the client did not specify any session ID, this method returns false.
getSession(),
getValidSession()RequestDispatcher getRequestDispatcher(java.lang.String path)
RequestDispatcher object that acts as a wrapper for the resource located at the given path.RequestDispatcher object or null if the handler corresponding to the path is not
found.HttpContext getContext()
HttpContext.