mx4j.tools.adaptor.http

Class HttpInputStream

public class HttpInputStream extends BufferedInputStream

HttpInputStream processes an HTTP request

Version: $Revision: 1.3 $

Constructor Summary
HttpInputStream(InputStream in)
Constructs a new HttpInputStream
Method Summary
StringgetHeader(String name)
Returns a given header by name, assumes lower case
MapgetHeaders()
Returns a given header by name, assumes lower case
StringgetMethod()
Returns the method of the request
StringgetPath()
Returns the path of the request
StringgetQueryString()
Returns the query string
StringgetVariable(String name)
Returns one variable value.
MapgetVariables()
Returns a map with the variables passed in the request.
String[]getVariableValues(String name)
Returns one variable values.
floatgetVersion()
Returns the version of the request
protected voidparseMethod(String method)
Parses the connection method.
protected voidparseRequest(String request)
Parses the request
protected voidparseVariables()
Parses the request parameters
protected voidparseVersion(String verStr)
Parses the request HttpConstants version
protected voidreadHeaders()
Reads the headers
StringreadLine()
Reads an HTTP line
voidreadRequest()
Reads the request parsing the headers

Constructor Detail

HttpInputStream

public HttpInputStream(InputStream in)
Constructs a new HttpInputStream

Parameters: in InputStream

Method Detail

getHeader

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

Parameters: name Name of the header

Returns: The header value

getHeaders

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

Parameters: name Name of the header

Returns: The header value

getMethod

public String getMethod()
Returns the method of the request

Returns: the method of the request GET/POST

getPath

public String getPath()
Returns the path of the request

Returns: the path of the request

getQueryString

public String getQueryString()
Returns the query string

Returns: The queryString value

getVariable

public String getVariable(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

getVariables

public 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[]

getVariableValues

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

Returns: A String array with all variable instances

getVersion

public float getVersion()
Returns the version of the request

Returns: The version value 1.0/1.1

parseMethod

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

Parameters: method Description of Parameter

Throws: HttpException Description of Exception

parseRequest

protected void parseRequest(String request)
Parses the request

Parameters: request Request string

Throws: HttpException Thrown if an error ocurr

parseVariables

protected void parseVariables()
Parses the request parameters

parseVersion

protected void parseVersion(String verStr)
Parses the request HttpConstants version

Parameters: verStr String containing the HTTP version

Throws: HttpException

readHeaders

protected void readHeaders()
Reads the headers

Throws: IOException

readLine

public String readLine()
Reads an HTTP line

Returns: A read line

Throws: IOException Emmited in case of errors reading the stream

readRequest

public void readRequest()
Reads the request parsing the headers

Throws: IOException Description of Exception

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