webcore.webserver
Class HTTPRequest

java.lang.Object
  |
  +--webcore.webserver.HTTPRequest

public class HTTPRequest
extends java.lang.Object

Class to hold the HTTPRequest from the browser.

An instance of this class is passed to WebRequestables to handle the request. There are methods to get the form variables and output stream from the request.


Field Summary
static java.lang.String HD_CONTENT_LEN
           
static java.lang.String HD_CONTENT_TYPE
           
static java.lang.String HD_COOKIE
           
static java.lang.String HD_HOST
           
static java.lang.String HD_METHOD_GET
           
static java.lang.String HD_METHOD_POST
           
static java.lang.String HD_MULTIPART_BOUNDARY
           
static java.lang.String HD_MULTIPART_CONTENT
           
static java.lang.String HD_USERAGENT
           
static long MAX_CONTENT_LENGTH
           
 
Constructor Summary
HTTPRequest(java.net.Socket requestSocket, java.lang.String requestStr, java.lang.String docBase)
          constructs a new HTTPRequest after the request HTTP header has been read from the stream.
 
Method Summary
 void close()
          flushes output streams and closes the socket
 java.lang.String getCookie(java.lang.String cookieName)
          returns the value of a cookie.
 java.lang.String[] getCookieNames()
          Returns an array containing all the available cookie names provided by the request
 java.lang.String getDocBase()
          returns the document base, which is passed to the request from the webserver
 java.lang.String getFormVar(java.lang.String formVariable)
          returns the string value of a form variable, if the variable is not found, null is returned If the content type is multipart/form-data, the variables must be read manually.
 java.lang.String[] getFormVariableNames()
          returns all the form variables If the content type is multipart/form-data, the variables must be read manually.
 java.lang.String getHost()
          returns the host passed in the HTTP header
 java.io.InputStream getInputStream()
          returns the InputStream to write to for this request
 java.lang.String getMethod()
          returns the method in the HTTP header (GET or POST are supported)
 java.io.OutputStream getOutputStream()
          returns the OutputStream to write to for this request
 java.io.PrintWriter getPrintWriter()
          returns a PrintWriter to write to the output stream for this request.
 java.lang.String getRequestedFile()
          returns the URI with the slashes converted to the local filesystem
 java.lang.String getRequestedObject()
          returns the URI
 java.lang.String getRequestedPath()
          returns full path to the requested file based on the document base
 java.net.Socket getRequestSocket()
           
 boolean isProcessed()
          determine if the request has been process or not
 void setProcessed(boolean value)
          if an event listener to the WebServer processes the request, it should set the httpRequests processed property to TRUE using this method
 java.lang.String toString()
          returns the request object string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HD_METHOD_GET

public static final java.lang.String HD_METHOD_GET
See Also:
Constant Field Values

HD_METHOD_POST

public static final java.lang.String HD_METHOD_POST
See Also:
Constant Field Values

HD_COOKIE

public static final java.lang.String HD_COOKIE
See Also:
Constant Field Values

HD_CONTENT_LEN

public static final java.lang.String HD_CONTENT_LEN
See Also:
Constant Field Values

HD_CONTENT_TYPE

public static final java.lang.String HD_CONTENT_TYPE
See Also:
Constant Field Values

HD_HOST

public static final java.lang.String HD_HOST
See Also:
Constant Field Values

HD_USERAGENT

public static final java.lang.String HD_USERAGENT
See Also:
Constant Field Values

HD_MULTIPART_CONTENT

public static final java.lang.String HD_MULTIPART_CONTENT
See Also:
Constant Field Values

HD_MULTIPART_BOUNDARY

public static final java.lang.String HD_MULTIPART_BOUNDARY
See Also:
Constant Field Values

MAX_CONTENT_LENGTH

public static final long MAX_CONTENT_LENGTH
See Also:
Constant Field Values
Constructor Detail

HTTPRequest

public HTTPRequest(java.net.Socket requestSocket,
                   java.lang.String requestStr,
                   java.lang.String docBase)
            throws java.io.IOException
constructs a new HTTPRequest after the request HTTP header has been read from the stream.

Post data has not been read yet.

Method Detail

getRequestSocket

public java.net.Socket getRequestSocket()

getPrintWriter

public java.io.PrintWriter getPrintWriter()
                                   throws java.io.IOException
returns a PrintWriter to write to the output stream for this request.

java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
returns the OutputStream to write to for this request

java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
returns the InputStream to write to for this request

java.io.IOException

close

public void close()
           throws java.io.IOException
flushes output streams and closes the socket

java.io.IOException

getDocBase

public java.lang.String getDocBase()
returns the document base, which is passed to the request from the webserver


getRequestedObject

public java.lang.String getRequestedObject()
returns the URI


getRequestedFile

public java.lang.String getRequestedFile()
returns the URI with the slashes converted to the local filesystem


getRequestedPath

public java.lang.String getRequestedPath()
returns full path to the requested file based on the document base


getHost

public java.lang.String getHost()
returns the host passed in the HTTP header


getMethod

public java.lang.String getMethod()
returns the method in the HTTP header (GET or POST are supported)


getFormVariableNames

public java.lang.String[] getFormVariableNames()
returns all the form variables

If the content type is multipart/form-data, the variables must be read manually.


getFormVar

public java.lang.String getFormVar(java.lang.String formVariable)
returns the string value of a form variable, if the variable is not found, null is returned

If the content type is multipart/form-data, the variables must be read manually.


getCookieNames

public java.lang.String[] getCookieNames()
Returns an array containing all the available cookie names provided by the request


getCookie

public java.lang.String getCookie(java.lang.String cookieName)
returns the value of a cookie. If the cookie is not found, null is returned.


toString

public java.lang.String toString()
returns the request object string

Overrides:
toString in class java.lang.Object

isProcessed

public boolean isProcessed()
determine if the request has been process or not


setProcessed

public void setProcessed(boolean value)
if an event listener to the WebServer processes the request, it should set the httpRequests processed property to TRUE using this method