juju.reattore.protocol.http.impl
Class BaseHttpRequest

java.lang.Object
  |
  +--juju.reattore.protocol.http.impl.BaseHttpRequest
All Implemented Interfaces:
HttpMessage, HttpRequest

public class BaseHttpRequest
extends java.lang.Object
implements HttpRequest

HTTP request implementation. Wraps a HTTP parser and provides the request access methods. Also acts as a proxy, only resolving certain fields as required.

See Also:
HttpRequest

Constructor Summary
BaseHttpRequest()
           
 
Method Summary
 void addHeader(java.lang.String name, java.lang.String val)
          Receives a new header from the parser.
 void changePath(java.lang.String to)
          Override the current path.
 ByteSource getBody()
          Gets the message body as a stream.
 java.lang.String getHeader(java.lang.String key)
          Gets a header line.
 java.util.Set getHeaders()
          Gets all headers as a set of Map.Entry items.
 java.lang.String getMethod()
          Gets the request method, such as GET, POST, or PUT.
 int getNumHeaders()
          Gets the number of parsed headers not including the start line.
 java.lang.String getOriginalPath()
          Gets the original request path, such as /dir/file.html.
 java.lang.String getPath()
          Gets the request path, such as /dir/file.html.
 java.lang.String getQueryString()
          Gets the request query string, such as name=val&name=val
 java.lang.String getVersion()
          Gets the request HTTP version, such as HTTP/1.1
 void setBody(ByteSource body)
          Sets the body attached to this request.
 void setStartLine(java.lang.String method, java.lang.String path, java.lang.String query, java.lang.String version)
          Bulk populate this request with the given values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseHttpRequest

public BaseHttpRequest()
Method Detail

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String val)
Receives a new header from the parser.

Parameters:
name - Name of the header
val - Value of

setStartLine

public void setStartLine(java.lang.String method,
                         java.lang.String path,
                         java.lang.String query,
                         java.lang.String version)
Bulk populate this request with the given values.

Parameters:
method - As named
path - As named
query - As named
version - As named

getHeader

public java.lang.String getHeader(java.lang.String key)
Description copied from interface: HttpMessage
Gets a header line.

Specified by:
getHeader in interface HttpMessage
Parameters:
key - The header to get.
Returns:
The header line as a string or null if it doesn't exist.
See Also:
HttpMessage

setBody

public void setBody(ByteSource body)
Sets the body attached to this request.

Parameters:
body - The new body.

getMethod

public java.lang.String getMethod()
Description copied from interface: HttpRequest
Gets the request method, such as GET, POST, or PUT.

Specified by:
getMethod in interface HttpRequest
Returns:
The request method.
See Also:
HttpRequest

getPath

public java.lang.String getPath()
Description copied from interface: HttpRequest
Gets the request path, such as /dir/file.html.

Specified by:
getPath in interface HttpRequest
Returns:
The request path.
See Also:
HttpRequest

getQueryString

public java.lang.String getQueryString()
Description copied from interface: HttpRequest
Gets the request query string, such as name=val&name=val

Specified by:
getQueryString in interface HttpRequest
Returns:
The request query string.
See Also:
HttpRequest

getVersion

public java.lang.String getVersion()
Description copied from interface: HttpRequest
Gets the request HTTP version, such as HTTP/1.1

Specified by:
getVersion in interface HttpRequest
Returns:
The request query string or "" if missing
See Also:
HttpRequest

getBody

public ByteSource getBody()
Description copied from interface: HttpMessage
Gets the message body as a stream. Will always be present, even if it is of zero length.

Specified by:
getBody in interface HttpMessage
Returns:
The request body.
See Also:
HttpRequest

getNumHeaders

public int getNumHeaders()
Description copied from interface: HttpMessage
Gets the number of parsed headers not including the start line.

Specified by:
getNumHeaders in interface HttpMessage
Returns:
The number of header lines.
See Also:
HttpMessage

getOriginalPath

public java.lang.String getOriginalPath()
Description copied from interface: HttpRequest
Gets the original request path, such as /dir/file.html.

Specified by:
getOriginalPath in interface HttpRequest
Returns:
The request path.
See Also:
HttpRequest

changePath

public void changePath(java.lang.String to)
Description copied from interface: HttpRequest
Override the current path.

Specified by:
changePath in interface HttpRequest
Parameters:
to - The new path to use. Does not change the original.
See Also:
HttpRequest

getHeaders

public java.util.Set getHeaders()
Description copied from interface: HttpMessage
Gets all headers as a set of Map.Entry items.

Specified by:
getHeaders in interface HttpMessage
Returns:
Set of (name, value) pairs.
See Also:
HttpMessage


Copyright © 2002-2003 Michael Hope. All Rights Reserved.