dfischer.femtowebserver.httpd
Class HttpRequest

java.lang.Object
  |
  +--dfischer.femtowebserver.httpd.HttpRequest

public class HttpRequest
extends java.lang.Object

Allows Weblets and SSSIs to access the HTTP request data (browser request).

More information about the HTTP protocol is available at http://www.w3.org

See Also:
HttpdWebletInterface, HttpdSssiInterface, HttpUploadFile

Method Summary
 void dump()
          Dumps the http request to stdout.
 java.lang.String getBasicAuthorizationPassword()
          Returns the (basic) authorization password, which has been set by the agent (browser).
 java.lang.String getBasicAuthorizationUsername()
          Returns the (basic) authorization username, which has been set by the agent (browser).
 byte[] getContent()
          Returns the content data of the request.
 java.lang.String getContentSubtype()
          Returns the MIME subtype of the request content data, if this information has been set by the agent (browser).
 java.lang.String getContentType()
          Returns the MIME type of the request content data, if this information has been set by the agent (browser).
 java.lang.String[] getHeader()
          Returns the whole HTTP request header.
 java.lang.String getHeaderField(java.lang.String headerFieldName)
          Returns the value of a header field name.
 java.lang.String[] getHeaderFieldNames()
          Returns a list of all request header field names (header line 1..n-1).
 java.lang.String getHttpProtocol()
          Returns the HTTP protocol version ("HTTP/1.0", "HTTP/1.1" ...) of the agent (browser).
 java.lang.String getMethod()
          Returns the HTTP request method ("GET", "POST" ...).
 java.lang.String getParameter(java.lang.String parameterName)
          Returns the value of a request parameter.
 java.lang.String getParameter(java.lang.String parameterName, boolean asRawValue)
          Returns the value of a request parameter.
 int getParameterAsInt(java.lang.String parameterName)
          Returns the value of a request parameter as int number.
 java.lang.String[] getParameterNames()
          Returns a list of all names of the request parameters, nevertheless if there is a "GET" or a "POST" request.
 java.lang.String getProtocol()
          Returns the request network-protocol.
 java.lang.String getQueryString()
          Returns all request parameter names and values.
 java.lang.String getRemoteAddress()
          Returns the TCP/IP remote address of the agent (browser).
 java.lang.String getRequest()
          Returns the request file with the full path.
 java.lang.String getRequestFile()
          Returns the request file without any path.
 java.lang.String getRequestPath()
          Returns the path to the request file (without the request file itself).
 HttpUploadFile getUploadFile(java.lang.String parameterName)
          Returns an uploaded file with its data, selected by the HTML parameter name.
 HttpUploadFile[] getUploadFiles()
          Returns all uploaded files.
 java.lang.String getURI()
          Returns the request URI.
 java.lang.String getUserAgent()
          Returns the browser product name and version (if any).
 java.lang.String getVirtualHost()
          Returns the name of the TCP/IP host to which the agent (browser) has made the request.
 int getVirtualPort()
          Returns the non-standard port number to which the agent (browser) has made the request.
 boolean hasBasicAuthorization()
          Checks if a base64 (basic) authorization has been set by the agent (browser).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRemoteAddress

public java.lang.String getRemoteAddress()
Returns the TCP/IP remote address of the agent (browser).
Returns:
TCP/IP remote address

getHeader

public java.lang.String[] getHeader()
Returns the whole HTTP request header.
Returns:
HTTP request header
See Also:
getHeaderFieldNames(), getHeaderField(java.lang.String)

getHeaderFieldNames

public java.lang.String[] getHeaderFieldNames()
Returns a list of all request header field names (header line 1..n-1).
Returns:
list of all request header field names
See Also:
getHeaderField(java.lang.String), getHeader()

getHeaderField

public java.lang.String getHeaderField(java.lang.String headerFieldName)
Returns the value of a header field name.
Parameters:
headerFieldName - name of the header field (not upper-/lower-case sensitive).
Returns:
value of a header field or null, if the header field was not found.
See Also:
getHeaderFieldNames(), getHeader()

getMethod

public java.lang.String getMethod()
Returns the HTTP request method ("GET", "POST" ...).
Returns:
HTTP request method in UPPERCASE

getURI

public java.lang.String getURI()
Returns the request URI. This is the request file (inclusive path) and with the optional CGI parameters.
Returns:
the request URI
See Also:
getRequest(), getParameter(java.lang.String)

getProtocol

public java.lang.String getProtocol()
Returns the request network-protocol. This is always "http" because https is not supported at the moment.
Returns:
the request network-protocol in lowercase letters.

getHttpProtocol

public java.lang.String getHttpProtocol()
Returns the HTTP protocol version ("HTTP/1.0", "HTTP/1.1" ...) of the agent (browser).
Returns:
HTTP protocol version in UPPERCASE

getUserAgent

public java.lang.String getUserAgent()
Returns the browser product name and version (if any).
Returns:
the browser product name and version or null, if no such information has been transfered from the browser

getVirtualHost

public java.lang.String getVirtualHost()
Returns the name of the TCP/IP host to which the agent (browser) has made the request.
Returns:
the name of the TCP/IP host to which the agent (browser) has made the request or null, if no such information has been transferred from the browser
See Also:
HttpdProperties.getServerName()

getVirtualPort

public int getVirtualPort()
Returns the non-standard port number to which the agent (browser) has made the request. If the agent has made a request to the standard HTTP port 80, this method returns -1. It returns also -1 if no such information has been transferred from the browser.
Returns:
the non-standard port number or -1
See Also:
HttpdProperties.getServerPort()

getContentType

public java.lang.String getContentType()
Returns the MIME type of the request content data, if this information has been set by the agent (browser).
Returns:
MIME type of the request content data in UPPERCASE or null, if no such information has been set by the agent (browser)
See Also:
getContentSubtype(), getContent()

getContentSubtype

public java.lang.String getContentSubtype()
Returns the MIME subtype of the request content data, if this information has been set by the agent (browser).
Returns:
MIME subtype of the request content data or null, if no such information has been set by the agent (browser)
See Also:
getContentType()

getContent

public byte[] getContent()
Returns the content data of the request. Consider that the HTTP request method "GET" never transfer a request content. If the HTTP request method is "POST" there will be in the most cases request content data transfered.
Returns:
the HTTP request content data or null, if no request content data has been transferred.
See Also:
getParameterNames(), getParameter(java.lang.String)

getQueryString

public java.lang.String getQueryString()
Returns all request parameter names and values. If the HTTP request type is "GET", this method will return the CGI parameters. IF the HTTP request type is "POST", the request content data will be returned.
Returns:
all request parameter names and values or null, if no such data are available.
See Also:
getParameterNames(), getParameter(java.lang.String)

getRequestPath

public java.lang.String getRequestPath()
Returns the path to the request file (without the request file itself). If there is no path because a file has been requested on the top of the CLASSPATH, an empty string will be returned.
Returns:
the path to the request file or an empty string, if no path is available.
See Also:
getRequestFile()

getRequestFile

public java.lang.String getRequestFile()
Returns the request file without any path. Does not include the (optional) CGI parameters.
Returns:
the request file without any path
See Also:
getRequestPath()

getRequest

public java.lang.String getRequest()
Returns the request file with the full path. Does not include the (optional) CGI parameters.
Returns:
the request file with the full path
See Also:
getRequestPath(), getRequestFile(), getURI()

getParameterNames

public java.lang.String[] getParameterNames()
Returns a list of all names of the request parameters, nevertheless if there is a "GET" or a "POST" request.
Returns:
a list of all names of the request parameters. If there are no request parameters, the list will be empty.
See Also:
getParameter(java.lang.String), getParameterAsInt(java.lang.String)

getParameter

public java.lang.String getParameter(java.lang.String parameterName)
Returns the value of a request parameter.
Parameters:
parameterName - the name of the request parameter
Returns:
the value of the request parameter or null, if there is no such parameter available.
See Also:
getParameter(String, boolean), getParameterNames(), getParameterAsInt(java.lang.String)

getParameter

public java.lang.String getParameter(java.lang.String parameterName,
                                     boolean asRawValue)
Returns the value of a request parameter.
Parameters:
parameterName - the name of the request parameter
asRawValue - if true, don't decode the value from the MIME "x-www-form-urlencoded" format
Returns:
the value of the request parameter or null, if there is no such parameter available.
See Also:
getParameter(String), getParameterNames(), getParameterAsInt(java.lang.String)

getParameterAsInt

public int getParameterAsInt(java.lang.String parameterName)
Returns the value of a request parameter as int number.
Parameters:
parameterName - the name of the request parameter
Returns:
the value of the request parameter as int number or -1, if there is no such parameter available - or also -1, if the parameter value can't be converted to an int number.
See Also:
getParameterNames(), getParameter(java.lang.String)

getUploadFile

public HttpUploadFile getUploadFile(java.lang.String parameterName)
Returns an uploaded file with its data, selected by the HTML parameter name.
Parameters:
parameterName - HTML parameter name
Returns:
uploaded file or null, if no file has been uploaded with this HTML parameter name.
See Also:
getUploadFiles()

getUploadFiles

public HttpUploadFile[] getUploadFiles()
Returns all uploaded files.
Returns:
uploaded files or an empty array, if no files have been uploaded. The return value will never be null.
See Also:
getUploadFile(java.lang.String)

hasBasicAuthorization

public boolean hasBasicAuthorization()
Checks if a base64 (basic) authorization has been set by the agent (browser). This is typically the agent reaction to a "401 Authorization Required" web server response.
Returns:
true, if the HTTP request contains a base64 (basic) authorization
See Also:
getBasicAuthorizationUsername(), getBasicAuthorizationPassword()

getBasicAuthorizationUsername

public java.lang.String getBasicAuthorizationUsername()
Returns the (basic) authorization username, which has been set by the agent (browser). This is typically the agent reaction to a "401 Authorization Required" web server response.
Returns:
the (basic) authorization username or null, if no authorization username has been set.
See Also:
getBasicAuthorizationPassword(), hasBasicAuthorization()

getBasicAuthorizationPassword

public java.lang.String getBasicAuthorizationPassword()
Returns the (basic) authorization password, which has been set by the agent (browser). This is typically the agent reaction to a "401 Authorization Required" web server response.
Returns:
the (basic) authorization password or null, if no authorization password has been set.
See Also:
getBasicAuthorizationUsername(), hasBasicAuthorization()

dump

public void dump()
Dumps the http request to stdout. Useful for debugging.
See Also:
Stdout