org.webbitserver
Interface HttpRequest

All Superinterfaces:
DataHolder
All Known Implementing Classes:
HttpRequestWrapper, NettyHttpRequest, StubHttpRequest

public interface HttpRequest
extends DataHolder

Retrieves information about inbound HTTP request.

Author:
Joe Walnes
See Also:
HttpHandler, HttpResponse

Field Summary
static String COOKIE_HEADER
           
 
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
 HttpRequest data(String key, Object value)
          Store data value by key.
 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 uri()
           
 HttpRequest uri(String uri)
          Modify uri
 
Methods inherited from interface org.webbitserver.DataHolder
data, data, dataKeys
 

Field Detail

COOKIE_HEADER

static final String COOKIE_HEADER
See Also:
Constant Field Values
Method Detail

uri

String uri()

uri

HttpRequest uri(String uri)
Modify uri

Parameters:
uri - new uri

header

String header(String name)
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 headers(String).


headers

List<String> headers(String name)
Retrieve all values for an HTTP header. If no values are found, an empty List is returned.


hasHeader

boolean hasHeader(String name)
Whether a specific HTTP header was present in the request.


cookies

List<HttpCookie> cookies()
Returns:
all inbound cookies

cookie

HttpCookie cookie(String name)
Get a cookie with a specific name

Parameters:
name - cookie name
Returns:
cookie with that name

queryParam

String queryParam(String key)
Get query parameter value.

Parameters:
key - parameter name
Returns:
the value of the parameter
See Also:
queryParams(String)

queryParams

List<String> queryParams(String key)
Get all query parameter values.

Parameters:
key - parameter name
Returns:
the values of the parameter
See Also:
queryParam(String)

queryParamKeys

Set<String> queryParamKeys()
List all query parameter keys.

See Also:
queryParam(String)

postParam

String postParam(String key)
Get post parameter value.

Parameters:
key - parameter name
Returns:
the value of the parameter
See Also:
postParams(String)

postParams

List<String> postParams(String key)
Get all post parameter values.

Parameters:
key - parameter name
Returns:
the values of the parameter
See Also:
postParam(String)

postParamKeys

Set<String> postParamKeys()
List all post parameter keys.

See Also:
postParam(String)

cookieValue

String cookieValue(String name)
Get the value of named cookie

Parameters:
name - cookie name
Returns:
cookie value, or null if the cookie does not exist.

allHeaders

List<Map.Entry<String,String>> allHeaders()
Returns all headers sent from client.


method

String method()
HTTP method (e.g. "GET" or "POST")


body

String body()
The body


bodyAsBytes

byte[] bodyAsBytes()
The body's byte array


data

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

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

remoteAddress

SocketAddress remoteAddress()
Remote address of connection (i.e. the host of the client).


id

Object id()
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.


timestamp

long timestamp()
Timestamp (millis since epoch) of when this request was first received by the server.



Copyright © 2012. All Rights Reserved.