org.webbitserver.netty
Class NettyHttpRequest

java.lang.Object
  extended by org.webbitserver.netty.NettyHttpRequest
All Implemented Interfaces:
DataHolder, HttpRequest

public class NettyHttpRequest
extends Object
implements HttpRequest


Field Summary
 
Fields inherited from interface org.webbitserver.HttpRequest
COOKIE_HEADER
 
Constructor Summary
NettyHttpRequest(org.jboss.netty.channel.MessageEvent messageEvent, org.jboss.netty.handler.codec.http.HttpRequest httpRequest, Object id, long timestamp)
           
 
Method Summary
 List<Map.Entry<String,String>> allHeaders()
          Returns all headers sent from client.
 String body()
          The body
 byte[] bodyAsBytes()
          The body's byte array
 HttpCookie cookie(String name)
          Get a cookie with a specific name
 List<HttpCookie> cookies()
           
 String cookieValue(String name)
          Get the value of named cookie
 Map<String,Object> data()
          Arbitrary data that can be stored for the lifetime of the connection.
 Object data(String key)
          Retrieve data value by key.
 NettyHttpRequest data(String key, Object value)
          Store data value by key.
 Set<String> dataKeys()
          List data keys.
 boolean hasHeader(String name)
          Whether a specific HTTP header was present in the request.
 String header(String name)
          Retrieve the value single HTTP header.
 List<String> headers(String name)
          Retrieve all values for an HTTP header.
 Object id()
          A unique identifier for this request.
 String method()
          HTTP method (e.g.
 String postParam(String key)
          Get post parameter value.
 Set<String> postParamKeys()
          List all post parameter keys.
 List<String> postParams(String key)
          Get all post parameter values.
 String queryParam(String key)
          Get query parameter value.
 Set<String> queryParamKeys()
          List all query parameter keys.
 List<String> queryParams(String key)
          Get all query parameter values.
 SocketAddress remoteAddress()
          Remote address of connection (i.e.
 long timestamp()
          Timestamp (millis since epoch) of when this request was first received by the server.
 String toString()
           
 String uri()
           
 NettyHttpRequest uri(String uri)
          Modify uri
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NettyHttpRequest

public NettyHttpRequest(org.jboss.netty.channel.MessageEvent messageEvent,
                        org.jboss.netty.handler.codec.http.HttpRequest httpRequest,
                        Object id,
                        long timestamp)
Method Detail

uri

public String uri()
Specified by:
uri in interface HttpRequest

uri

public NettyHttpRequest uri(String uri)
Description copied from interface: HttpRequest
Modify uri

Specified by:
uri in interface HttpRequest
Parameters:
uri - new uri

header

public String header(String name)
Description copied from interface: HttpRequest
Retrieve the value single HTTP header.

If the header is not found, null is returned.

If there are multiple headers with the same name, it will return one of them, but it is not defined which one. Instead, use HttpRequest.headers(String).

Specified by:
header in interface HttpRequest

headers

public List<String> headers(String name)
Description copied from interface: HttpRequest
Retrieve all values for an HTTP header. If no values are found, an empty List is returned.

Specified by:
headers in interface HttpRequest

hasHeader

public boolean hasHeader(String name)
Description copied from interface: HttpRequest
Whether a specific HTTP header was present in the request.

Specified by:
hasHeader in interface HttpRequest

cookies

public List<HttpCookie> cookies()
Specified by:
cookies in interface HttpRequest
Returns:
all inbound cookies

cookie

public HttpCookie cookie(String name)
Description copied from interface: HttpRequest
Get a cookie with a specific name

Specified by:
cookie in interface HttpRequest
Parameters:
name - cookie name
Returns:
cookie with that name

queryParam

public String queryParam(String key)
Description copied from interface: HttpRequest
Get query parameter value.

Specified by:
queryParam in interface HttpRequest
Parameters:
key - parameter name
Returns:
the value of the parameter
See Also:
HttpRequest.queryParams(String)

queryParams

public List<String> queryParams(String key)
Description copied from interface: HttpRequest
Get all query parameter values.

Specified by:
queryParams in interface HttpRequest
Parameters:
key - parameter name
Returns:
the values of the parameter
See Also:
HttpRequest.queryParam(String)

queryParamKeys

public Set<String> queryParamKeys()
Description copied from interface: HttpRequest
List all query parameter keys.

Specified by:
queryParamKeys in interface HttpRequest
See Also:
HttpRequest.queryParam(String)

postParam

public String postParam(String key)
Description copied from interface: HttpRequest
Get post parameter value.

Specified by:
postParam in interface HttpRequest
Parameters:
key - parameter name
Returns:
the value of the parameter
See Also:
HttpRequest.postParams(String)

postParams

public List<String> postParams(String key)
Description copied from interface: HttpRequest
Get all post parameter values.

Specified by:
postParams in interface HttpRequest
Parameters:
key - parameter name
Returns:
the values of the parameter
See Also:
HttpRequest.postParam(String)

postParamKeys

public Set<String> postParamKeys()
Description copied from interface: HttpRequest
List all post parameter keys.

Specified by:
postParamKeys in interface HttpRequest
See Also:
HttpRequest.postParam(String)

cookieValue

public String cookieValue(String name)
Description copied from interface: HttpRequest
Get the value of named cookie

Specified by:
cookieValue in interface HttpRequest
Parameters:
name - cookie name
Returns:
cookie value, or null if the cookie does not exist.

allHeaders

public List<Map.Entry<String,String>> allHeaders()
Description copied from interface: HttpRequest
Returns all headers sent from client.

Specified by:
allHeaders in interface HttpRequest

method

public String method()
Description copied from interface: HttpRequest
HTTP method (e.g. "GET" or "POST")

Specified by:
method in interface HttpRequest

body

public String body()
Description copied from interface: HttpRequest
The body

Specified by:
body in interface HttpRequest

bodyAsBytes

public byte[] bodyAsBytes()
Description copied from interface: HttpRequest
The body's byte array

Specified by:
bodyAsBytes in interface HttpRequest

data

public Map<String,Object> data()
Description copied from interface: DataHolder
Arbitrary data that can be stored for the lifetime of the connection.

Specified by:
data in interface DataHolder

data

public Object data(String key)
Description copied from interface: DataHolder
Retrieve data value by key.

Specified by:
data in interface DataHolder
See Also:
DataHolder.data()

data

public NettyHttpRequest data(String key,
                             Object value)
Description copied from interface: DataHolder
Store data value by key.

Specified by:
data in interface DataHolder
Specified by:
data in interface HttpRequest
See Also:
DataHolder.data()

dataKeys

public Set<String> dataKeys()
Description copied from interface: DataHolder
List data keys.

Specified by:
dataKeys in interface DataHolder
See Also:
DataHolder.data()

remoteAddress

public SocketAddress remoteAddress()
Description copied from interface: HttpRequest
Remote address of connection (i.e. the host of the client).

Specified by:
remoteAddress in interface HttpRequest

id

public Object id()
Description copied from interface: HttpRequest
A unique identifier for this request. This should be treated as an opaque object, that can be used to track the lifecycle of a request.

Specified by:
id in interface HttpRequest

timestamp

public long timestamp()
Description copied from interface: HttpRequest
Timestamp (millis since epoch) of when this request was first received by the server.

Specified by:
timestamp in interface HttpRequest

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.