wt.httpgw
Class HTTPRequest

java.lang.Object
  extended bywt.httpgw.HTTPRequest
All Implemented Interfaces:
CGIConstants, Serializable
Direct Known Subclasses:
HTTPRequestImpl, HTTPServletRequest

public abstract class HTTPRequest
extends Object
implements CGIConstants, Serializable

This class is a carrier of HTTP request information to a Windchill method server. It uses customized serialization code to stream request bodies to the server. Instances contain information about the request (I.e. CGI environment values) and an input stream reference.

Client-side Serialization The client (HTTP gateway) constructs request objects to carry request information to a method server. The client stores the available HTTP request information in the object and sets the input stream reference to the actual HTTP request's input stream provided by the Web server.

Serialization of the object sends the request information followed by the content of the input stream. The content is forwarded by reading blocks of data from the input stream and writing them to the marshal stream until the entire body has been sent. The length of the body is determined from the content-length HTTP header. If no content-length is specified, it reads until EOF on the input stream.

Server-side Deserialization The server (Windchill method server) receives the request object as an argument to an RMI call. It is deserialized before the target method is invoked. The deserialization code stores a reference to the RMI marshal stream in the object and directly dispatches the target method (HTTPServer.processRequest) prematurely. The body of the request is then available as an input stream to the dispatched method. The RMI marshal stream is simply being used as a pipe to connect the input stream provided to the HTTP gateway by the Web server to an input stream in the Windchill method server.

Supported API: true
Extendable: false

See Also:
Serialized Form

Field Summary
 Object bizData
          Public Object for general use by business classes to facilitate passing info across method calls, etc.
 InputStream inputStream
          Public InputStream for general use.
(package private)  HTTPResponse response
          Result object created during server-side unmarshalling
(package private) static long serialVersionUID
           
 
Fields inherited from interface wt.httpgw.CGIConstants
CGI_ACCEPT, CGI_ACCEPT_CHARSET, CGI_ACCEPT_LANGUAGE, CGI_AUTH_TYPE, CGI_AUTHORIZATION, CGI_CONNECTION, CGI_CONTENT_LENGTH, CGI_CONTENT_TYPE, CGI_CONTEXT_PATH, CGI_DELETE_METHOD, CGI_GATEWAY_INTERFACE, CGI_GET_METHOD, CGI_HEAD_METHOD, CGI_HOST, CGI_IF_MODIFIED_SINCE, CGI_MULTIPART_BOUNDARY, CGI_PATH_INFO, CGI_PATH_TRANSLATED, CGI_POST_METHOD, CGI_PRAGMA, CGI_PROPERTY_PREFIX, CGI_PROTOCOL, CGI_PUT_METHOD, CGI_QUERY_STRING, CGI_REFERER, CGI_REMOTE_ADDR, CGI_REMOTE_HOST, CGI_REMOTE_IDENT, CGI_REMOTE_USER, CGI_REQUEST_METHOD, CGI_SCHEME, CGI_SCRIPT_NAME, CGI_SERVER_NAME, CGI_SERVER_PORT, CGI_SERVER_PROTOCOL, CGI_SERVER_SOFTWARE, CGI_SERVLET_SESSION, CGI_TRACE_METHOD, CGI_UA_COLOR, CGI_UA_CPU, CGI_UA_OS, CGI_UA_PIXELS, CGI_URI, CGI_URL, CGI_USER_AGENT, versionID
 
Constructor Summary
HTTPRequest()
           
 
Method Summary
abstract  String getBaseURL()
          Determine the Base URL of this script.
abstract  String getEncoding()
          Guess user agent's file encoding from request headers.
abstract  Properties getFormData()
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
abstract  Properties getFormData(String encoding)
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
abstract  Hashtable getFormDataMultivalue()
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
abstract  Hashtable getFormDataMultivalue(String encoding)
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
abstract  String getFullURL()
          Determine the Full URL of this script.
abstract  String getMultiPartBoundary(String ContentType)
          Utility routine to parse out the multipart object-body boundary

Supported API: true
abstract  String getProperty(String key)
          Public getter method for access to CGI data.
abstract  String getProperty(String key, String default_value)
          Public getter method for access to CGI data.
abstract  Enumeration getPropertyKeys()
          Public getter method for access to CGI data keys.
abstract  String getQueryString()
          Gets the URLs query string in decoded format.
abstract  String getQueryString(String encoding)
          Gets the URLs query string in decoded format.
abstract  boolean isGetRequest()
          Determine if the REQUEST_METHOD used to send the data from the browser was the GET method.
abstract  boolean isPostRequest()
          Determine if the REQUEST_METHOD used to send the data from the browser was the POST method.
abstract  boolean isUrlencodedContent()
          Determine if the CONTENT_TYPE used to send the data from the browser was urlencoded form data.
abstract  void listProperties(PrintWriter out)
          Public lister method for debug access to CGI data.
abstract  PrintWriter newPrintWriter(OutputStream output_stream)
          Utility routine to construct a buffered PrintWriter from an OutputStream.
abstract  void printFormDataHTML(PrintWriter out)
          Print all of the form data using HTML.
abstract  void printHTMLBottom(PrintWriter out)
          Generate some vanilla HTML that you usually want to include at the bottom of any HTML page you generate.
abstract  void printHTMLHeader(PrintWriter out)
          Print a standard HTTP HTML header.
abstract  void printHTMLTop(PrintWriter out, String title)
          Generate some vanilla HTML that you usually want to include at the top of any HTML page you generate.
abstract  void printPropertiesHTML(PrintWriter out)
          Print all of the CGI properties and the associated values using HTML.
abstract  void setFormData(Properties p)
          Sets the FORM data from a saved session.
abstract  void setProperty(String key, String value)
          Public setter method for CGI data.
abstract  Properties splitQueryString()
          Splits the URLs query string into name value pairs based on the ampersand and equal character tokens.
private static void splitQueryString(Hashtable result, String query_string, String encoding)
           
static Properties splitQueryString(String query_string)
          Splits the given query string into name value pairs based on the ampersand and equal character tokens.
static Properties splitQueryString(String query_string, String encoding)
          Splits the URLs query string into name value pairs based on the ampersand and equal character tokens.
abstract  Hashtable splitQueryStringMultivalue()
          Splits the URLs query string into name value pairs based on the ampersand and equal character tokens.
static Hashtable splitQueryStringMultivalue(String query_string)
          Splits the given query string into name value pairs based on the ampersand and equal character tokens.
static Hashtable splitQueryStringMultivalue(String query_string, String encoding)
          Splits the URLs query string into name value pairs based on the ampersand and equal character tokens.
static String urlDecode(String encoded)
          Deprecated. Replaced by wt.httpgw.WTURLEncoder.decode method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputStream

public transient InputStream inputStream
Public InputStream for general use.


serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

response

transient HTTPResponse response
Result object created during server-side unmarshalling


bizData

public transient Object bizData
Public Object for general use by business classes to facilitate passing info across method calls, etc.

A business class can set this Object to reference any object desired in one method. Then retrieve it with an appropriate type cast in another method.

This allows the method reading a posted request body to construct an arbitrary object and make it available later when the response is being written.

Constructor Detail

HTTPRequest

public HTTPRequest()
Method Detail

getFormData

public abstract Properties getFormData()
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string. All hex escaped characters are decoded, then the sequence of 8-bit values is converted to characters using the character encoding returned by getEncoding.

Supported API: true

Returns:
Properties the form data as name value pairs.

setFormData

public abstract void setFormData(Properties p)
Sets the FORM data from a saved session.

Supported API: true


getFormData

public abstract Properties getFormData(String encoding)
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string. All hex escaped characters are decoded, then the sequence of 8-bit values is converted to characters using the given character encoding.

Supported API: true

Returns:
Properties the form data as name value pairs.

getFormDataMultivalue

public abstract Hashtable getFormDataMultivalue()
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string. All hex escaped characters are decoded, then the sequence of 8-bit values is converted to characters using the character encoding returned by getEncoding. Multivalue fields are stored in a Vector which can be iterated for the individual values.

Supported API: true

Returns:
Properties the form data as name value pairs.

getFormDataMultivalue

public abstract Hashtable getFormDataMultivalue(String encoding)
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string. All hex escaped characters are decoded, then the sequence of 8-bit values is converted to characters using the given character encoding. Multivalue fields are stored in a Vector which can be iterated for the individual values.

Supported API: true

Returns:
Properties the form data as name value pairs.

getQueryString

public abstract String getQueryString()
Gets the URLs query string in decoded format. All hex escaped characters are decoded. The sequence of 8-bit values is then converted to characters using UTF8 encoding.

Supported API: true

Returns:
String the decoded query string.

getQueryString

public abstract String getQueryString(String encoding)
Gets the URLs query string in decoded format. All hex escaped characters are decoded. The sequence of 8-bit values is then converted to characters using the given character encoding.

Supported API: true

Returns:
String the decoded query string.

splitQueryString

public abstract Properties splitQueryString()
Splits the URLs query string into name value pairs based on the ampersand and equal character tokens. The returned properties are URL decoded and then converted to characters using UTF8 encoding.

Supported API: true

Returns:
Properties the query string info as name value pairs.

splitQueryStringMultivalue

public abstract Hashtable splitQueryStringMultivalue()
Splits the URLs query string into name value pairs based on the ampersand and equal character tokens. The returned properties are URL decoded and then converted to characters using UTF8 encoding.

Supported API: true

Returns:
Properties the query string info as name value pairs.

splitQueryString

public static Properties splitQueryString(String query_string)
Splits the given query string into name value pairs based on the ampersand and equal character tokens. The string should not yet be URL decoded, since some of the names or values might themselves contain the ampersand and equal characters. The returned properties are URL decoded and then converted to characters using UTF8 encoding.

Supported API: true

Parameters:
query_string - the query string.
Returns:
Properties the query string info as name value pairs.

splitQueryStringMultivalue

public static Hashtable splitQueryStringMultivalue(String query_string)
Splits the given query string into name value pairs based on the ampersand and equal character tokens. The string should not yet be URL decoded, since some of the names or values might themselves contain the ampersand and equal characters. The returned properties are URL decoded and then converted to characters using UTF8 encoding.

Supported API: true

Parameters:
query_string - the query string.
Returns:
Properties the query string info as name value pairs.

splitQueryString

public static Properties splitQueryString(String query_string,
                                          String encoding)
Splits the URLs query string into name value pairs based on the ampersand and equal character tokens. The string should not yet be URL decoded, since some of the names or values might themselves contain the ampersand and equal characters. The returned properties are URL decoded and then converted to characters using the given encoding. Non-string values (ie Multivalue parameters are stored in vector) are converted to a toString() format.

Supported API: true

Parameters:
query_string - the query string.
encoding - the character encoding name
Returns:
Properties the query string info as name value pairs.

splitQueryStringMultivalue

public static Hashtable splitQueryStringMultivalue(String query_string,
                                                   String encoding)
Splits the URLs query string into name value pairs based on the ampersand and equal character tokens. The string should not yet be URL decoded, since some of the names or values might themselves contain the ampersand and equal characters. The returned properties are URL decoded and then converted to characters using the given encoding. Multivalue parameters are stored in a vector which can be iterated for the individual values.

Supported API: true

Parameters:
query_string - the query string.
encoding - the character encoding name
Returns:
Hashtable the query string info as name value pairs.

splitQueryString

private static void splitQueryString(Hashtable result,
                                     String query_string,
                                     String encoding)

urlDecode

public static String urlDecode(String encoded)
Deprecated. Replaced by wt.httpgw.WTURLEncoder.decode method.

URL decode a string.

Data passed through the CGI API is URL encoded by the browser. All spaces are turned into plus characters (+) and all "special" characters are hex escaped into a %dd format (where dd is the hex ASCII value that represents the original character).

Supported API: false

Returns:
The decoded string.

isGetRequest

public abstract boolean isGetRequest()
Determine if the REQUEST_METHOD used to send the data from the browser was the GET method.

Supported API: true

Returns:
true, if the REQUEST_METHOD was GET. false, otherwise.

isPostRequest

public abstract boolean isPostRequest()
Determine if the REQUEST_METHOD used to send the data from the browser was the POST method.

Supported API: true

Returns:
true, if the REQUEST_METHOD was POST. false, otherwise.

isUrlencodedContent

public abstract boolean isUrlencodedContent()
Determine if the CONTENT_TYPE used to send the data from the browser was urlencoded form data.

Supported API: true

Returns:
true, if the CONTENT_TYPE was urlencoded form data. false, otherwise.

getBaseURL

public abstract String getBaseURL()
Determine the Base URL of this script. (Does not include the QUERY_STRING (if any) or PATH_INFO (if any).

Supported API: true

Returns:
The Base URL of this script as a String.

getFullURL

public abstract String getFullURL()
Determine the Full URL of this script. (Includes the QUERY_STRING (if any) or PATH_INFO (if any).

Supported API: true

Returns:
The Full URL of this script as a String.

getProperty

public abstract String getProperty(String key)
Public getter method for access to CGI data.

Supported API: true

Returns:
String the value

getPropertyKeys

public abstract Enumeration getPropertyKeys()
Public getter method for access to CGI data keys.

Supported API: true

Returns:
Enumeration of the keys

listProperties

public abstract void listProperties(PrintWriter out)
Public lister method for debug access to CGI data. Output is not formated. For formated output (html), see the printPropertiesHTML method below.

Supported API: false


getProperty

public abstract String getProperty(String key,
                                   String default_value)
Public getter method for access to CGI data. If not set, default value is returned.

Supported API: true

Returns:
String the value

setProperty

public abstract void setProperty(String key,
                                 String value)
Public setter method for CGI data.

Supported API: true


getEncoding

public abstract String getEncoding()
Guess user agent's file encoding from request headers. If Accept-Charset is specified, use the first value and apply a mapping of IANA names to Java encoding names. Mapping can be controlled at runtime with properties of the form wt.httpgw.encoding.xxx=yyy where xxx is the lower case IANA encoding name and yyy is the Java encoding name. If no Accept-Charset header is present, use template encoding rules to guess.

Supported API: true

Returns:
String the encoding name

printHTMLHeader

public abstract void printHTMLHeader(PrintWriter out)
                              throws IOException
Print a standard HTTP HTML header.

Supported API: false

Parameters:
out - PrintWriter to receive output.
Returns:
A String containing the standard HTTP HTML header.
Throws:
IOException

printHTMLTop

public abstract void printHTMLTop(PrintWriter out,
                                  String title)
                           throws IOException
Generate some vanilla HTML that you usually want to include at the top of any HTML page you generate.

Supported API: false

Parameters:
out - PrintWriter to receive output.
Returns:
A String containing the top portion of an HTML file.
Throws:
IOException

printHTMLBottom

public abstract void printHTMLBottom(PrintWriter out)
                              throws IOException
Generate some vanilla HTML that you usually want to include at the bottom of any HTML page you generate.

Supported API: false

Parameters:
out - PrintWriter to receive output.
Returns:
A String containing the bottom portion of an HTML file.
Throws:
IOException

printPropertiesHTML

public abstract void printPropertiesHTML(PrintWriter out)
                                  throws IOException
Print all of the CGI properties and the associated values using HTML.

Supported API: false

Parameters:
out - PrintWriter to receive output.
Throws:
IOException

printFormDataHTML

public abstract void printFormDataHTML(PrintWriter out)
                                throws IOException
Print all of the form data using HTML.

Supported API: false

Parameters:
out - PrintWriter to receive output.
Throws:
IOException

newPrintWriter

public abstract PrintWriter newPrintWriter(OutputStream output_stream)
Utility routine to construct a buffered PrintWriter from an OutputStream.

Supported API: true

Parameters:
output_stream - OutputStream to be wrapped
Returns:
A buffered PrintWriter constructed around the given OutPutStream.

getMultiPartBoundary

public abstract String getMultiPartBoundary(String ContentType)
Utility routine to parse out the multipart object-body boundary

Supported API: true

Parameters:
ContentType - String containing the content-type and boundary, separated by a semi-colon
Returns:
A String containing the object-body boundary, not to exceed 70 characters per RFC1341