|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.awf.web.http.HttpRequestImpl
public class HttpRequestImpl
| Field Summary | |
|---|---|
static Pattern |
COOKIE_SEPARATOR_PATTERN
Regex to split cookie header following RFC6265 Section 5.4 |
static Pattern |
KEY_VALUE_PATTERN
Regex to parse out key/value pairs |
static Pattern |
PARAM_STRING_PATTERN
Regex to parse out parameters from query string |
static Pattern |
QUERY_STRING_PATTERN
Regex to parse out QueryString from HttpRequest |
static Pattern |
REQUEST_LINE_PATTERN
Regex to parse HttpRequest Request Line |
| Constructor Summary | |
|---|---|
HttpRequestImpl()
|
|
HttpRequestImpl(String requestLine,
Map<String,String> headers)
Creates a new HttpRequest |
|
| Method Summary | |
|---|---|
boolean |
expectContinue()
Check if the request expect a response with 100 Continue header |
String |
getBody()
The body of this request |
protected DynamicByteBuffer |
getBodyBuffer()
|
int |
getContentLength()
compute contentLength with header content-length when needed. |
protected HttpParsingContext |
getContext()
|
String |
getCookie(String name)
Returns a given cookie. |
Map<String,String> |
getCookies()
Returns a map with all cookies contained in the request. |
String |
getHeader(String name)
Get the value of a given HTTP header. |
Map<String,String> |
getHeaders()
Get the read-only header of this request. |
HttpVerb |
getMethod()
The method (POST,GET ..) used for this request. |
String |
getParameter(String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist. |
Map<String,Collection<String>> |
getParameters()
Returns a map of all parameters where each key is a parameter name, linked value is a Collection of String containing all known values for the parameter. |
Collection<String> |
getParameterValues(String name)
Returns a collection of all values associated with the provided parameter. |
InetAddress |
getRemoteHost()
The address of the client which issued this request. |
int |
getRemotePort()
The TCP port of the client which issued this request. |
String |
getRequestedPath()
The path of this request Ex : http://www.w3.org/pub/WWW/TheProject.html |
String |
getRequestLine()
Get the HTTP request line for the request. |
InetAddress |
getServerHost()
The address of the server which received this request. |
int |
getServerPort()
The TCP port of the server which received this request. |
String |
getVersion()
The version of the HTTP protocol. |
protected void |
initKeepAlive()
|
protected boolean |
isFinished()
|
boolean |
isKeepAlive()
Does keep-alive was requested. |
protected void |
pushToHeaders(String name,
String value)
Append the given value to the specified header. |
protected void |
setMethod(HttpVerb method)
|
protected void |
setRemoteHost(InetAddress host)
|
protected void |
setRemotePort(int port)
|
protected void |
setServerHost(InetAddress host)
|
protected void |
setServerPort(int port)
|
protected void |
setURI(String uri)
Sets the requestedPath and parse parameters using the received complete URI |
protected void |
setVersion(String version)
|
String |
toString()
TODO SLM This should output the real request and use a StringBuilder |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Pattern REQUEST_LINE_PATTERN
public static final Pattern QUERY_STRING_PATTERN
public static final Pattern PARAM_STRING_PATTERN
public static final Pattern KEY_VALUE_PATTERN
public static final Pattern COOKIE_SEPARATOR_PATTERN
| Constructor Detail |
|---|
public HttpRequestImpl()
public HttpRequestImpl(String requestLine,
Map<String,String> headers)
requestLine - The Http request text lineheaders - The Http request headers| Method Detail |
|---|
public String getRequestLine()
HttpRequestEx :
GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1
getRequestLine in interface HttpRequestpublic String getRequestedPath()
HttpRequestEx :
http://www.w3.org/pub/WWW/TheProject.html
getRequestedPath in interface HttpRequestpublic String getVersion()
HttpRequestCan be HTTP/1.0 or HTTP/1.1.
getVersion in interface HttpRequestpublic Map<String,String> getHeaders()
HttpRequest
getHeaders in interface HttpRequestHttpRequest.getHeader(String)public String getHeader(String name)
HttpRequest
getHeader in interface HttpRequestname - the name of the requested header
null if the header is not found.HttpRequest.getHeaders()public HttpVerb getMethod()
HttpRequest
getMethod in interface HttpRequestHttpVerbpublic String getParameter(String name)
getParameter in interface HttpRequestpublic Map<String,Collection<String>> getParameters()
HttpRequest
getParameters in interface HttpRequestpublic String getBody()
HttpRequest
getBody in interface HttpRequestStringpublic InetAddress getRemoteHost()
HttpRequest
getRemoteHost in interface HttpRequestpublic InetAddress getServerHost()
HttpRequest
getServerHost in interface HttpRequestInetAddress representing the server address.public int getRemotePort()
HttpRequest
getRemotePort in interface HttpRequestpublic int getServerPort()
HttpRequest
getServerPort in interface HttpRequestprotected void setRemoteHost(InetAddress host)
protected void setServerHost(InetAddress host)
protected void setRemotePort(int port)
protected void setServerPort(int port)
public Map<String,String> getCookies()
getCookies in interface HttpRequestpublic String getCookie(String name)
getCookie in interface HttpRequestname - the name of cookie
public Collection<String> getParameterValues(String name)
getParameterValues in interface HttpRequestpublic boolean isKeepAlive()
HttpRequest
isKeepAlive in interface HttpRequesttrue if keep-alive requestedpublic String toString()
toString in class Objectprotected void initKeepAlive()
protected HttpParsingContext getContext()
protected void setMethod(HttpVerb method)
protected void setURI(String uri)
uri - protected void setVersion(String version)
protected void pushToHeaders(String name,
String value)
public int getContentLength()
protected DynamicByteBuffer getBodyBuffer()
protected boolean isFinished()
public boolean expectContinue()
HttpRequest
expectContinue in interface HttpRequest
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||