org.xlightweb
Class HttpRequest

Package class diagram package HttpRequest
java.lang.Object
  extended by org.xlightweb.Part
      extended by org.xlightweb.HttpRequest
All Implemented Interfaces:
IHeader, IHttpMessage, IHttpRequest, IPart
Direct Known Subclasses:
DeleteRequest, GetRequest, HeadRequest, MultipartRequest, OptionsRequest, PostRequest, PutRequest

public class HttpRequest
extends Part
implements IHttpRequest

http request


Field Summary
 
Fields inherited from interface org.xlightweb.IHttpMessage
CONNECT_METHOD, DEFAULT_ENCODING, DEFAULT_ENCODING_KEY, DELETE_METHOD, GET_METHOD, HEAD_METHOD, OPTIONS_METHOD, POST_METHOD, PUT_METHOD, TRACE_METHOD
 
Constructor Summary
HttpRequest(IHttpRequestHeader requestHeader)
          constructor
HttpRequest(IHttpRequestHeader requestHeader, byte[] bodyData)
          constructor
HttpRequest(IHttpRequestHeader requestHeader, ByteBuffer[] bodyData)
          constructor
HttpRequest(IHttpRequestHeader requestHeader, ByteBuffer[] bodyData, boolean compress)
          constructor
HttpRequest(IHttpRequestHeader requestHeader, InputStream is)
          constructor.
HttpRequest(IHttpRequestHeader requestHeader, List<ByteBuffer> bodyData)
          constructor
HttpRequest(IHttpRequestHeader requestHeader, List<ByteBuffer> bodyData, boolean compress)
          constructor
HttpRequest(IHttpRequestHeader requestHeader, NonBlockingBodyDataSource bodyDataSource)
          constructor
HttpRequest(IHttpRequestHeader requestHeader, String body)
          constructor
HttpRequest(IHttpRequestHeader requestHeader, String body, boolean compress)
          constructor
HttpRequest(String method, String url)
          constructor
HttpRequest(String method, String url, String contentType, byte[] body)
          constructor
HttpRequest(String method, String url, String contentType, byte[] body, boolean compress)
          constructor
HttpRequest(String method, String url, String contentType, ByteBuffer[] body)
          constructor
HttpRequest(String method, String url, String contentType, ByteBuffer[] body, boolean compress)
          constructor
HttpRequest(String method, String url, String contentType, String body)
          constructor
HttpRequest(String method, String url, String contentType, String body, boolean compress)
          constructor
HttpRequest(String method, String url, String contentType, String encoding, String body)
          constructor
HttpRequest(String method, String url, String contentType, String encoding, String body, boolean compress)
          constructor
 
Method Summary
 void addMatrixParameter(String parameterName, String parameterValue)
          adds a matrix parameter
 void addParameter(String parameterName, String parameterValue)
          adds a parameter
 List<ContentType> getAccept()
          returns the list of the accepted content types, ordered by the quality factory
 Object getAttribute(String name)
          Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
 Enumeration getAttributeNames()
          Returns an Enumeration containing the names of the attributes available to this message.
 Set<String> getAttributeNameSet()
          Returns an Set containing the names of the attributes available to this messaget.
 Boolean getBooleanParameter(String name)
          Get an Boolean parameter, or null if not present.
 boolean getBooleanParameter(String name, boolean defaultVal)
          Get an boolean parameter, with a fallback value.
 int getContentLength()
          Returns the length, in bytes, of the message body and made available by the input stream, or -1 if the length is not known.
 String getContextPath()
          Returns the portion of the request URI that indicates the context of the request.
 Double getDoubleParameter(String name)
          Get an Double parameter, or null if not present.
 double getDoubleParameter(String name, double defaultVal)
          Get an double parameter, with a fallback value.
 Float getFloatParameter(String name)
          Get an Float parameter, or null if not present.
 float getFloatParameter(String name, float defaultVal)
          Get an float parameter, with a fallback value.
 String getHost()
          returns the Host header parameter or null if the header is not set
 Integer getIntParameter(String name)
          Get an Integer parameter, or null if not present.
 int getIntParameter(String name, int defaultVal)
          Get an int parameter, with a fallback value.
 Long getLongParameter(String name)
          Get an Long parameter, or null if not present.
 long getLongParameter(String name, long defaultVal)
          Get an long parameter, with a fallback value.
 String getMatrixParameter(String name)
          Returns the value of a request matrix parameter as a String, or null if the parameter does not exist.
 Set<String> getMatrixParameterNameSet()
          returns the matrix parameter name set
 String[] getMatrixParameterValues(String name)
          Returns an array of String objects containing all of the values the given request matrix parameter has, or null if the parameter does not exist.
 IHttpMessageHeader getMessageHeader()
          returns the message header
 String getMethod()
          Returns 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 a request parameter as a String, or null if the parameter does not exist.
 String getParameter(String name, String defaultVal)
          Get an String parameter, with a fallback value.
 Enumeration getParameterNames()
          Returns an Enumeration of String objects containing the names of the parameters contained in this request.
 Set<String> getParameterNameSet()
          returns the parameter name set
 String[] getParameterValues(String name)
          Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
 String getPathInfo()
          Returns any extra path information associated with the URL.
 String getPathInfo(boolean removeSurroundingSlashs)
          Returns any extra path information associated with the URL.
 String getProtocol()
          Returns the name and version of the protocol the message uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
 String getProtocolVersion()
          Returns the version of the protocol the message uses in the form majorVersion.minorVersion, for example, 1.1.
 String getQueryString()
          Returns the query string that is contained in the request URL after the path.
 String getRemoteAddr()
          Returns the Internet Protocol (IP) address of the client or last proxy that sent the message.
 String getRemoteHost()
          Returns the fully qualified name of the client or the last proxy that sent the request.
 int getRemotePort()
          Returns the Internet Protocol (IP) source port of the client or last proxy that sent the message.
 String getRequestHandlerPath()
          returns the request handler path.
 IHttpRequestHeader getRequestHeader()
          returns the request header
 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.
 URL getRequestUrl()
          Reconstructs the URL the client used to make the request.
 boolean getRequiredBooleanParameter(String name)
          Get an boolean parameter or throws an exception if parameter is not present
 double getRequiredDoubleParameter(String name)
          Get an double parameter or throws an exception if parameter is not present
 float getRequiredFloatParameter(String name)
          Get an float parameter or throws an exception if parameter is not present
 int getRequiredIntParameter(String name)
          Get an int parameter or throws an exception if parameter is not present
 long getRequiredLongParameter(String name)
          Get an long parameter or throws an exception if parameter is not present
 String getRequiredStringParameter(String name)
          Get an string parameter or throws an exception if parameter is not present
 String getScheme()
          Returns the name of the scheme used to make this request, for example, http or https.
 String getServerName()
          Returns the host name of the server to which the request was sent.
 int getServerPort()
          Returns the port number to which the request was sent.
 String getUserAgent()
          returns the User-Agent header parameter or null if the header is not set
 boolean isSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
 void removeHopByHopHeaders()
          removes all hop-by-hop headers without Transfer-Encoding if set to chunked
 void removeMatrixParameter(String parameterName)
          removes a matrix parameter
 void removeParameter(String parameterName)
          remove a parameter
 void setAttribute(String name, Object o)
          Stores an attribute in this header.
 void setContentLength(int length)
          sets the content length in bytes
 void setContextPath(String contextPath)
          sets the context path.
 void setHost(String host)
          sets the Host header
 void setMatrixParameter(String parameterName, String parameterValue)
          sets a matrix parameter
 void setMethod(String method)
          Sets the name of the HTTP method
 void setParameter(String parameterName, String parameterValue)
          sets a parameter
 void setRequestHandlerPath(String requestHandlerPath)
          sets the request handler path
 void setRequestURI(String requestUri)
          set the request uri part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 void setRequestUrl(URL url)
          set the request url
 void setUserAgent(String userAgent)
          sets the User-Agent header
 
Methods inherited from class org.xlightweb.Part
addHeader, addHeaderLine, addHeaderlines, containsHeader, getBlockingBody, getBody, getCharacterEncoding, getContentType, getDisposition, getDispositionParam, getDispositionType, getHeader, getHeaderList, getHeaderNames, getHeaderNameSet, getHeaders, getNonBlockingBody, getPartHeader, getTransferEncoding, hasBody, removeHeader, setContentType, setHeader, setTransferEncoding, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xlightweb.IHttpMessage
getAttribute, getAttributeNames, getAttributeNameSet, getCharacterEncoding, getContentLength, getContentType, getMessageHeader, getTransferEncoding, removeHopByHopHeaders, setAttribute, setContentLength, setContentType, setTransferEncoding
 
Methods inherited from interface org.xlightweb.IPart
getBlockingBody, getBody, getNonBlockingBody, getPartHeader, hasBody
 
Methods inherited from interface org.xlightweb.IHeader
addHeader, addHeaderLine, addHeaderlines, containsHeader, getDisposition, getDispositionParam, getDispositionType, getHeader, getHeaderList, getHeaderNames, getHeaderNameSet, getHeaders, removeHeader, setHeader
 

Constructor Detail

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader)
constructor

Parameters:
requestHeader - the request header

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   NonBlockingBodyDataSource bodyDataSource)
            throws IOException
constructor

Parameters:
requestHeader - the request header
bodyDataSource - the body data source
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   ByteBuffer[] bodyData,
                   boolean compress)
            throws IOException
constructor

Parameters:
requestHeader - the request header
bodyData - the body data
compress - true, if the body should be compressed
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   InputStream is)
            throws IOException
constructor. The input stream will be read by a background thread. If the end of stream is reached, it will be closed

Parameters:
requestHeader - the request header
is - the body data
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url,
                   String contentType,
                   ByteBuffer[] body,
                   boolean compress)
            throws IOException
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
contentType - the content type
body - the body
compress - true, if the body should be compressed
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url,
                   String contentType,
                   byte[] body,
                   boolean compress)
            throws IOException
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
contentType - the content type
body - the body
compress - true, if the body should be compressed
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url,
                   String contentType,
                   String encoding,
                   String body,
                   boolean compress)
            throws IOException
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
contentType - the content type
encoding - the encoding
body - the body
compress - true, if the body should be compressed
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url,
                   String contentType,
                   String body,
                   boolean compress)
            throws IOException
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
contentType - the content type
body - the body
compress - true, if the body should be compressed
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   String body,
                   boolean compress)
            throws IOException
constructor

Parameters:
requestHeader - the request header
body - the body
compress - true, if the body should be compressed
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   String body)
            throws IOException
constructor

Parameters:
requestHeader - the request header
body - the body
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   ByteBuffer[] bodyData)
            throws IOException
constructor

Parameters:
requestHeader - the request header
bodyData - the body data
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   byte[] bodyData)
            throws IOException
constructor

Parameters:
requestHeader - the request header
bodyData - the body data
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   List<ByteBuffer> bodyData)
            throws IOException
constructor

Parameters:
requestHeader - the request header
bodyData - the body data
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(IHttpRequestHeader requestHeader,
                   List<ByteBuffer> bodyData,
                   boolean compress)
            throws IOException
constructor

Parameters:
requestHeader - the request header
bodyData - the body data
compress - true, if the data should be compressed
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url,
                   String contentType,
                   String body)
            throws IOException
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
contentType - the content type
body - the body
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url,
                   String contentType,
                   String encoding,
                   String body)
            throws IOException
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
contentType - the content type
encoding - the encoding
body - the body
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url,
                   String contentType,
                   byte[] body)
            throws IOException
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
contentType - the content type
body - the body
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url,
                   String contentType,
                   ByteBuffer[] body)
            throws IOException
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
contentType - the content type
body - the body
Throws:
IOException - if an exception occurs

HttpRequest

public HttpRequest(String method,
                   String url)
constructor

Parameters:
method - the method (GET, POST, ...)
url - the url
Method Detail

getRequestHeader

public IHttpRequestHeader getRequestHeader()
returns the request header

Specified by:
getRequestHeader in interface IHttpRequest
Returns:
the request header

getRequestHandlerPath

public String getRequestHandlerPath()
returns the request handler path. By default this method returns "".

Example:

 class MyHandler implements IHttpRequestHandler {
 
    public void onRequest(IHttpExchange exchange) throws IOException,BadMessageException {
       IHttpRequest req = exchange.getRequest();
       
       StringBuilder sb = new StringBuilder();
       sb.append("path=" + req.getRequestHandlerPath() + "\r\n");
       sb.append("ctx=" + req.getContextPath() + "\r\n");
       sb.append("uri=" + req.getRequestURI() + "\r\n");
       
       exchange.send(new HttpResponse(200, "text/plain", sb.toString()));
    }
 }

 
  ...
  Context ctx = new Context("/ctx/subctx");
  ctx.addHandler("/hdlPath/*", new MyHandler());
  HttpServer server = new HttpServer(ctx);
  server.start();
  
  HttpClient httpClient = new HttpClient();
  IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx/subctx/hdlPath/test?param=value"));
  
  System.out.println(response.getBlockingBody().readString());
  // prints out:
  // >path=/hdlPath
  // >ctx=/ctx/subctx
  // >uri=/ctx/subctx/hdlPath/test

  ...
 
 

Specified by:
getRequestHandlerPath in interface IHttpRequest
Returns:
the request handler path

setRequestHandlerPath

public void setRequestHandlerPath(String requestHandlerPath)
sets the request handler path

Specified by:
setRequestHandlerPath in interface IHttpRequest
Parameters:
requestHandlerPath - the request handler path

getContextPath

public String getContextPath()
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. For the default (root) context, this method returns "".

Specified by:
getContextPath in interface IHttpRequest
Returns:
the context path
See Also:
IHttpRequest.getRequestHandlerPath()

setContextPath

public void setContextPath(String contextPath)
sets the context path.

Specified by:
setContextPath in interface IHttpRequest
Parameters:
contextPath - the context path

setMethod

public void setMethod(String method)
Sets the name of the HTTP method

Specified by:
setMethod in interface IHttpRequest
Parameters:
method - a String specifying the name of the method

getMethod

public String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

Specified by:
getMethod in interface IHttpRequest
Returns:
a String specifying the name of the method

getAccept

public List<ContentType> getAccept()
returns the list of the accepted content types, ordered by the quality factory

Specified by:
getAccept in interface IHttpRequest
Returns:
the accepted content types

getScheme

public String getScheme()
Returns the name of the scheme used to make this request, for example, http or https.

Specified by:
getScheme in interface IHttpRequest
Returns:
a String containing the name of the scheme

setHost

public void setHost(String host)
sets the Host header

Specified by:
setHost in interface IHttpRequest
Parameters:
host - the Host header

getServerName

public String getServerName()
Returns 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.

Specified by:
getServerName in interface IHttpRequest
Returns:
the server name

getServerPort

public int getServerPort()
Returns 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.

Specified by:
getServerPort in interface IHttpRequest
Returns:
the server port

getProtocol

public String getProtocol()
Returns the name and version of the protocol the message uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.

Specified by:
getProtocol in interface IHttpMessage
Returns:
a String containing the protocol name and version number

getProtocolVersion

public String getProtocolVersion()
Returns the version of the protocol the message uses in the form majorVersion.minorVersion, for example, 1.1.

Specified by:
getProtocolVersion in interface IHttpMessage
Returns:
a String containing the protocol version number

getRequestUrl

public URL getRequestUrl()
Reconstructs the URL the client used to make the request.

Specified by:
getRequestUrl in interface IHttpRequest
Returns:
the URL

setRequestUrl

public void setRequestUrl(URL url)
set the request url

Specified by:
setRequestUrl in interface IHttpRequest
Parameters:
url - the request url

getRemoteHost

public String getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.

Specified by:
getRemoteHost in interface IHttpRequest
Returns:
a String containing the fully qualified name of the client

getRemoteAddr

public String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the message.

Specified by:
getRemoteAddr in interface IHttpRequest
Returns:
a String containing the IP address of the client that sent the request

getRemotePort

public int getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the message.

Specified by:
getRemotePort in interface IHttpRequest
Returns:
an integer specifying the port number

getRequestURI

public 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.

Specified by:
getRequestURI in interface IHttpRequest
Returns:
a String containing the part of the URL from the protocol name up to the query string

setRequestURI

public void setRequestURI(String requestUri)
Description copied from interface: IHttpRequest
set the request uri part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Specified by:
setRequestURI in interface IHttpRequest
Parameters:
requestUri - the request uri

getPathInfo

public String getPathInfo()
Returns any extra path information associated with the URL. The extra path information follows the servlet path but precedes the query string and will start with a "/" character.

Specified by:
getPathInfo in interface IHttpRequest
Returns:
a String specifying extra path information that comes after the request handler and context path but before the query string in the request URL; or null if the URL does not have any extra path information

getPathInfo

public String getPathInfo(boolean removeSurroundingSlashs)
Returns any extra path information associated with the URL. The extra path information follows the servlet path but precedes the query string

Specified by:
getPathInfo in interface IHttpRequest
Parameters:
removeSurroundingSlashs - true, if surrounding slashs wil lbe removed
Returns:
a String specifying extra path information that comes after the request handler and context path but before the query string in the request URL; or null if the URL does not have any extra path information

getHost

public String getHost()
returns the Host header parameter or null if the header is not set

Specified by:
getHost in interface IHttpRequest
Returns:
the Host header parameter or null if the header is not set

getUserAgent

public String getUserAgent()
returns the User-Agent header parameter or null if the header is not set

Specified by:
getUserAgent in interface IHttpRequest
Returns:
the User-Agent header parameter or null if the header is not set

setUserAgent

public void setUserAgent(String userAgent)
sets the User-Agent header

Specified by:
setUserAgent in interface IHttpRequest
Parameters:
userAgent - the User-Agent header

getQueryString

public String getQueryString()
Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string.

Specified by:
getQueryString in interface IHttpRequest
Returns:
a String containing the query string or null if the URL contains no query string.

isSecure

public boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Specified by:
isSecure in interface IHttpRequest
Returns:
a boolean indicating if the request was made using a secure channel

getMatrixParameter

public String getMatrixParameter(String name)
Returns the value of a request matrix parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request.

Specified by:
getMatrixParameter in interface IHttpRequest
Parameters:
name - a String specifying the name of the matrix parameter
Returns:
a String representing the single value of the matrix parameter

getMatrixParameterNameSet

public Set<String> getMatrixParameterNameSet()
returns the matrix parameter name set

Specified by:
getMatrixParameterNameSet in interface IHttpRequest
Returns:
the matrix parameter name set

getMatrixParameterValues

public String[] getMatrixParameterValues(String name)
Returns an array of String objects containing all of the values the given request matrix parameter has, or null if the parameter does not exist. If the natrix parameter has a single value, the array has a length of 1.

Specified by:
getMatrixParameterValues in interface IHttpRequest
Parameters:
name - a String specifying the name of the matrix parameter
Returns:
an array of String objects containing the matrix parameter's values

setMatrixParameter

public void setMatrixParameter(String parameterName,
                               String parameterValue)
sets a matrix parameter

Specified by:
setMatrixParameter in interface IHttpRequest
Parameters:
parameterName - the parameter name
parameterValue - the parameter value

addMatrixParameter

public void addMatrixParameter(String parameterName,
                               String parameterValue)
adds a matrix parameter

Specified by:
addMatrixParameter in interface IHttpRequest
Parameters:
parameterName - the parameter name
parameterValue - the parameter value

removeMatrixParameter

public void removeMatrixParameter(String parameterName)
removes a matrix parameter

Specified by:
removeMatrixParameter in interface IHttpRequest
Parameters:
parameterName - the parameter name

getParameterNames

public Enumeration getParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.

Specified by:
getParameterNames in interface IHttpRequest
Returns:
an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters

getParameterNameSet

public Set<String> getParameterNameSet()
returns the parameter name set

Specified by:
getParameterNameSet in interface IHttpRequest
Returns:
the parameter name set

getParameter

public String getParameter(String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request.

Specified by:
getParameter in interface IHttpRequest
Parameters:
name - a String specifying the name of the parameter
Returns:
a String representing the single value of the parameter

getParameter

public String getParameter(String name,
                           String defaultVal)
Get an String parameter, with a fallback value.

Specified by:
getParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getParameterValues

public String[] getParameterValues(String name)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. If the parameter has a single value, the array has a length of 1.

Specified by:
getParameterValues in interface IHttpRequest
Parameters:
name - a String specifying the name of the parameter
Returns:
an array of String objects containing the parameter's values

getRequiredStringParameter

public String getRequiredStringParameter(String name)
                                  throws BadMessageException
Get an string parameter or throws an exception if parameter is not present

Specified by:
getRequiredStringParameter in interface IHttpRequest
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present

getIntParameter

public Integer getIntParameter(String name)
                        throws BadMessageException
Get an Integer parameter, or null if not present.

Specified by:
getIntParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
Returns:
the value, or null
Throws:
BadMessageException - if the parameter value is not a number

getRequiredIntParameter

public int getRequiredIntParameter(String name)
                            throws BadMessageException
Get an int parameter or throws an exception if parameter is not present

Specified by:
getRequiredIntParameter in interface IHttpRequest
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present or the parameter is not a number

getIntParameter

public int getIntParameter(String name,
                           int defaultVal)
Get an int parameter, with a fallback value.

Specified by:
getIntParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value, or null

getLongParameter

public Long getLongParameter(String name)
                      throws BadMessageException
Get an Long parameter, or null if not present.

Specified by:
getLongParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
Returns:
the value, or null
Throws:
BadMessageException - if the parameter value is not a number

getRequiredLongParameter

public long getRequiredLongParameter(String name)
                              throws BadMessageException
Get an long parameter or throws an exception if parameter is not present

Specified by:
getRequiredLongParameter in interface IHttpRequest
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present or the parameter is not a number

getLongParameter

public long getLongParameter(String name,
                             long defaultVal)
Get an long parameter, with a fallback value.

Specified by:
getLongParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getDoubleParameter

public Double getDoubleParameter(String name)
                          throws BadMessageException
Get an Double parameter, or null if not present.

Specified by:
getDoubleParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
Returns:
the value, or null
Throws:
BadMessageException - if the parameter is not a number

getRequiredDoubleParameter

public double getRequiredDoubleParameter(String name)
                                  throws BadMessageException
Get an double parameter or throws an exception if parameter is not present

Specified by:
getRequiredDoubleParameter in interface IHttpRequest
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present or the parameter value is not a number

getDoubleParameter

public double getDoubleParameter(String name,
                                 double defaultVal)
Get an double parameter, with a fallback value.

Specified by:
getDoubleParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getFloatParameter

public Float getFloatParameter(String name)
                        throws BadMessageException
Get an Float parameter, or null if not present.

Specified by:
getFloatParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
Returns:
the value, or null
Throws:
BadMessageException - if the parameter value is not a number

getRequiredFloatParameter

public float getRequiredFloatParameter(String name)
                                throws BadMessageException
Get an float parameter or throws an exception if parameter is not present

Specified by:
getRequiredFloatParameter in interface IHttpRequest
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present or the parameter value is not a number

getFloatParameter

public float getFloatParameter(String name,
                               float defaultVal)
Get an float parameter, with a fallback value.

Specified by:
getFloatParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

getBooleanParameter

public Boolean getBooleanParameter(String name)
Get an Boolean parameter, or null if not present.

Specified by:
getBooleanParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
Returns:
the value, or null

getRequiredBooleanParameter

public boolean getRequiredBooleanParameter(String name)
                                    throws BadMessageException
Get an boolean parameter or throws an exception if parameter is not present

Specified by:
getRequiredBooleanParameter in interface IHttpRequest
Parameters:
name - the parameter name
Returns:
the value
Throws:
BadMessageException - if the parameter is not present

getBooleanParameter

public boolean getBooleanParameter(String name,
                                   boolean defaultVal)
Get an boolean parameter, with a fallback value.

Specified by:
getBooleanParameter in interface IHttpRequest
Parameters:
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the value

setParameter

public void setParameter(String parameterName,
                         String parameterValue)
sets a parameter

Specified by:
setParameter in interface IHttpRequest
Parameters:
parameterName - the parameter name
parameterValue - the parameter value

removeParameter

public void removeParameter(String parameterName)
remove a parameter

Specified by:
removeParameter in interface IHttpRequest
Parameters:
parameterName - the parameter name

addParameter

public void addParameter(String parameterName,
                         String parameterValue)
adds a parameter

Specified by:
addParameter in interface IHttpRequest
Parameters:
parameterName - the parameter name
parameterValue - the parameter value

getMessageHeader

public final IHttpMessageHeader getMessageHeader()
returns the message header

Specified by:
getMessageHeader in interface IHttpMessage
Returns:
the message header

setAttribute

public final void setAttribute(String name,
                               Object o)
Stores an attribute in this header. Attributes are reset between messages.

Attribute names should follow the same conventions as package names.

Specified by:
setAttribute in interface IHttpMessage
Parameters:
name - a String specifying the name of the attribute
o - the Object to be stored

getAttribute

public final Object getAttribute(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Attribute names should follow the same conventions as package names.

Specified by:
getAttribute in interface IHttpMessage
Parameters:
name - a String specifying the name of the attribute
Returns:
an Object containing the value of the attribute, or null if the attribute does not exist

getAttributeNames

public final Enumeration getAttributeNames()
Returns an Enumeration containing the names of the attributes available to this message. This method returns an empty Enumeration if the message has no attributes available to it.

Specified by:
getAttributeNames in interface IHttpMessage
Returns:
an Enumeration of strings containing the names of the message's attributes

getAttributeNameSet

public final Set<String> getAttributeNameSet()
Returns an Set containing the names of the attributes available to this messaget. This method returns an empty Set if the request has no attributes available to it.

Specified by:
getAttributeNameSet in interface IHttpMessage
Returns:
an Set of strings containing the names of the message's attributes

getContentLength

public final int getContentLength()
Returns the length, in bytes, of the message body and made available by the input stream, or -1 if the length is not known.

Specified by:
getContentLength in interface IHttpMessage
Returns:
an integer containing the length of the message body or -1 if the length is not known

setContentLength

public final void setContentLength(int length)
sets the content length in bytes

Specified by:
setContentLength in interface IHttpMessage
Parameters:
length - the content length in bytes

removeHopByHopHeaders

public final void removeHopByHopHeaders()
removes all hop-by-hop headers without Transfer-Encoding if set to chunked

Specified by:
removeHopByHopHeaders in interface IHttpMessage