mx4j.tools.adaptor.http
Class HttpInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended byjava.io.BufferedInputStream
              extended bymx4j.tools.adaptor.http.HttpInputStream

public class HttpInputStream
extends java.io.BufferedInputStream

HttpInputStream processes an HTTP request

Version:
$Revision: 1.3 $

Field Summary
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
HttpInputStream(java.io.InputStream in)
          Constructs a new HttpInputStream
 
Method Summary
 java.lang.String getHeader(java.lang.String name)
          Returns a given header by name, assumes lower case
 java.util.Map getHeaders()
          Returns a given header by name, assumes lower case
 java.lang.String getMethod()
          Returns the method of the request
 java.lang.String getPath()
          Returns the path of the request
 java.lang.String getQueryString()
          Returns the query string
 java.lang.String getVariable(java.lang.String name)
          Returns one variable value.
 java.util.Map getVariables()
          Returns a map with the variables passed in the request.
 java.lang.String[] getVariableValues(java.lang.String name)
          Returns one variable values.
 float getVersion()
          Returns the version of the request
protected  void parseMethod(java.lang.String method)
          Parses the connection method.
protected  void parseRequest(java.lang.String request)
          Parses the request
protected  void parseVariables()
          Parses the request parameters
protected  void parseVersion(java.lang.String verStr)
          Parses the request HttpConstants version
protected  void readHeaders()
          Reads the headers
 java.lang.String readLine()
          Reads an HTTP line
 void readRequest()
          Reads the request parsing the headers
 
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpInputStream

public HttpInputStream(java.io.InputStream in)
Constructs a new HttpInputStream

Parameters:
in - InputStream
Method Detail

getMethod

public java.lang.String getMethod()
Returns the method of the request

Returns:
the method of the request GET/POST

getPath

public java.lang.String getPath()
Returns the path of the request

Returns:
the path of the request

getQueryString

public java.lang.String getQueryString()
Returns the query string

Returns:
The queryString value

getVersion

public float getVersion()
Returns the version of the request

Returns:
The version value 1.0/1.1

getHeader

public java.lang.String getHeader(java.lang.String name)
Returns a given header by name, assumes lower case

Parameters:
name - Name of the header
Returns:
The header value

getHeaders

public java.util.Map getHeaders()
Returns a given header by name, assumes lower case

Returns:
The header value

readRequest

public void readRequest()
                 throws java.io.IOException
Reads the request parsing the headers

Throws:
java.io.IOException - Description of Exception

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Reads an HTTP line

Returns:
A read line
Throws:
java.io.IOException - Emmited in case of errors reading the stream

getVariables

public java.util.Map getVariables()
Returns a map with the variables passed in the request.

Returns:
A map containing variables/value pairs. If a variable is

present only once in the request the value will be a String.

If it is present many times the variable will be a String[]


getVariable

public java.lang.String getVariable(java.lang.String name)
Returns one variable value. If the variable is present many times, the first

instance will be returned

Returns:
A String with the variable value

getVariableValues

public java.lang.String[] getVariableValues(java.lang.String name)
Returns one variable values.

Returns:
A String array with all variable instances

parseVariables

protected void parseVariables()
                       throws HttpException
Parses the request parameters

Throws:
HttpException

parseMethod

protected void parseMethod(java.lang.String method)
                    throws HttpException
Parses the connection method. GET/POST are allowed

Parameters:
method - Description of Parameter
Throws:
HttpException - Description of Exception

parseRequest

protected void parseRequest(java.lang.String request)
                     throws HttpException
Parses the request

Parameters:
request - Request string
Throws:
HttpException - Thrown if an error ocurr

parseVersion

protected void parseVersion(java.lang.String verStr)
                     throws HttpException
Parses the request HttpConstants version

Parameters:
verStr - String containing the HTTP version
Throws:
HttpException

readHeaders

protected void readHeaders()
                    throws java.io.IOException
Reads the headers

Throws:
java.io.IOException


Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.