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

String
getHeader(String name)
Returns a given header by name, assumes lower case
Map
getHeaders()
Returns a given header by name, assumes lower case
String
getMethod()
Returns the method of the request
String
getPath()
Returns the path of the request
String
getQueryString()
Returns the query string
String
getVariable(String name)
Returns one variable value.
String[]
getVariableValues(String name)
Returns one variable values.
Map
getVariables()
Returns a map with the variables passed in the request.
float
getVersion()
Returns the version of the request
protected void
parseMethod(String method)
Parses the connection method.
protected void
parseRequest(String request)
Parses the request
protected void
parseVariables()
Parses the request parameters
protected void
parseVersion(String verStr)
Parses the request HttpConstants version
protected void
readHeaders()
Reads the headers
String
readLine()
Reads an HTTP line
void
readRequest()
Reads the request parsing the headers

Constructor Details

HttpInputStream

public HttpInputStream(InputStream in)
Constructs a new HttpInputStream
Parameters:
in - InputStream

Method Details

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:
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

getVariableValues

public String[] getVariableValues(String name)
Returns one variable values.
Returns:
A String array with all variable instances

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


getVersion

public float getVersion()
Returns the version of the request
Returns:
The version value 1.0/1.1

parseMethod

protected void parseMethod(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(String request)
            throws HttpException
Parses the request
Parameters:
request - Request string
Throws:
HttpException - Thrown if an error ocurr

parseVariables

protected void parseVariables()
            throws HttpException
Parses the request parameters

parseVersion

protected void parseVersion(String verStr)
            throws HttpException
Parses the request HttpConstants version
Parameters:
verStr - String containing the HTTP version
Throws:
HttpException -

readHeaders

protected void readHeaders()
            throws IOException
Reads the headers

readLine

public String readLine()
            throws IOException
Reads an HTTP line
Returns:
A read line

readRequest

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

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