public abstract class HttpRequest extends HttpMessage
An HTTP request message.
| Constructor and Description |
|---|
HttpRequest() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
contentString() |
abstract Map<String,Object> |
getAtrributes()
Returns the names values of all attributed associated with this request.
|
Object |
getAttribute(String name)
Returns the value of the given attribute.
|
abstract String |
getContextPath()
The portion of the request URI that indicates the context of the request.
|
abstract long |
getDateHeader(String name)
Returns the value of the specified request header as a
long value that represents a Date object. |
abstract ActorRef<HttpResponse> |
getFrom()
Returns an actor representing the client to which an
HttpResponse should be sent as a response to this request. |
abstract String |
getMethod()
The name of the HTTP method with which this request was made; for example, GET, POST, or PUT.
|
String |
getParameter(String name)
Returns the value of the given parameter.
|
abstract Multimap<String,String> |
getParameters()
A multimap of the parameters contained in this message and (all) their values.
|
Collection<String> |
getParametersValues(String name)
Returns all values associated with the given parameter
|
abstract String |
getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request.
|
abstract String |
getQueryString()
The query string that is contained in the request URL after the path, or
null if the URL does not have a query string. |
abstract String |
getRequestURI()
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.
|
abstract String |
getServerName()
The host name of the server to which the request was sent.
|
abstract int |
getServerPort()
The port number to which the request was sent.
|
getCharacterEncoding, getContentLength, getContentType, getCookies, getHeader, getHeaders, getHeaderValuesgetByteBufferBody, getStringBodytoStringpublic abstract Multimap<String,String> getParameters()
A multimap of the parameters contained in this message and (all) their values. If the request has no parameters, returns an empty multimap.
public abstract Map<String,Object> getAtrributes()
Returns the names values of all attributed associated with this request.
The container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute javax.servlet.request.X509Certificate can be used to retrieve information on the certificate of the client.
Object containing the value of the attribute, or null if the attribute does not existpublic Collection<String> getParametersValues(String name)
Returns all values associated with the given parameter
name - the parameter namepublic String getParameter(String name)
Returns the value of the given parameter. If the parameter is not found in the message, this method returns null. If the parameter has more than one value, this method returns the first value.
name - the parameter namenull if the parameter is not foundpublic Object getAttribute(String name)
Returns the value of the given attribute. If the attribute is not found in the message, this method returns null.
name - the attribute namenull if the attribute is not foundpublic abstract String getMethod()
The name of the HTTP method with which this request was made; for example, GET, POST, or PUT.
public abstract long getDateHeader(String name)
Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.
The date is returned as the number of milliseconds since January 1, 1970 GMT.
If the request does 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 IllegalArgumentException.
name - the name of the headerlong value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the requestIllegalArgumentException - If the header value can’t be converted to a datepublic abstract String getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a “/” character.
This method returns null if there was no extra path information.
String decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path informationpublic abstract String getContextPath()
The portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a “/” character but does not end with a “/” character. For servlets in the default (root) context, this method returns "". The container does not decode this string.
It is possible that a container may match a context by more than one context path. In such cases this method will return the actual context path used by the request.
public abstract String getQueryString()
The query string that is contained in the request URL after the path, or null if the URL does not have a query string.
public abstract String getRequestURI()
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. The web container does not decode this string. For example:
| 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 |
public abstract String getServerName()
The host name of the server to which the request was sent. It is the value of the part before “:” in the Host header value, if any, or the resolved server name, or the server IP address.
public abstract int getServerPort()
The port number to which the request was sent. It is the value of the part after “:” in the Host header value, if any, or the server port where the client connection was accepted on.
public abstract ActorRef<HttpResponse> getFrom()
Returns an actor representing the client to which an HttpResponse should be sent as a response to this request. All HttpRequests from the same session will have the same sender. It will appear to have died (i.e. send an ExitMessage if watched) when the session is terminated.
getFrom in interface FromMessagegetFrom in class WebMessageprotected String contentString()
contentString in class WebMessage