com.ibm.wbi.protocol.http
Class HttpRequest

java.lang.Object
  |
  +--com.ibm.wbi.protocol.http.HttpBase
        |
        +--com.ibm.wbi.protocol.http.HttpRequest

Deprecated. Use the new HTTP header classes instead (HttpRequestHeader, HttpResponseHeader, HttpHeaderAscii).

public class HttpRequest
extends HttpBase

This class is used to manipulate HTTP 1.0 requests. It can be constructed with default value, from a request string, or from a MegInputStream (that comes from a RequestEvent).

The request can then be manipulated through various properties.

Finally, the request can be produced as a String, or written to the MegOutputStream associated with a RequestEvent.

See Also:
writeRequest(RequestEvent)., HttpHeaderAscii, HttpRequestHeader, HttpResponseHeader

Field Summary
static java.lang.String COPYRIGHT
          Deprecated.  
protected  HttpRequestHeader rheader
          Deprecated.  
 
Fields inherited from class com.ibm.wbi.protocol.http.HttpBase
content, header
 
Constructor Summary
HttpRequest()
          Deprecated. Construct a default HTTP 1.0 request, which is a "GET" of "http://www.ibm.com" with no other header information.
HttpRequest(HttpRequestHeader request)
          Deprecated.  
HttpRequest(ResponseToRequest rtr, boolean loadContent)
          Deprecated. Construct an HTTP 1.0 request from the request in the given MegInputStream.
HttpRequest(java.lang.String request)
          Deprecated. Construct an HTTP 1.0 request from a request String.
 
Method Summary
 void addQueryTerm(java.lang.String key, java.lang.String value)
          Deprecated. Add a term to the query portion of the request (following a '?' in a "GET" request).
 java.lang.String getCookie(java.lang.String name)
          Deprecated. Inefficient for accessing multiple cookies!
 java.util.Properties getCookies()
          Deprecated. Access the cookies that are being passed to the server with this request.
 java.lang.String getMethod()
          Deprecated. Access the HTTP request method.
static java.lang.String getPathFromFile(java.net.URL u)
          Deprecated. Return the path portion of the given URL, without the protocol, the server, or the query portion.
static java.lang.String getQueryFromFile(java.net.URL u)
          Deprecated. Return the query portion of the given URL, without the protocol, the server, or the file portion.
 java.lang.String getUrl()
          Deprecated. Access the HTTP request URL.
 void loadRequestContent(ResponseToRequest rtr)
          Deprecated. Load the request contents that are in the given MegInputStream.
static void main(java.lang.String[] args)
          Deprecated. Test Driver.
 void parseRequestHeader(java.lang.String request)
          Deprecated. Parse the HTTP request that is contained in the given String and set the properties in this object to correspond to that request.
 java.lang.String produceRequestWithContent()
          Deprecated. Produces request header up through the double \r\n, plus any request content
 java.lang.String produceRequestWithoutContent()
          Deprecated. Produces request header up through the double \r\n, but excludes any request content (e.g.
 java.net.URL produceURLObject()
          Deprecated. Converts the requested URL into a URL object.
 void setMethod(java.lang.String m)
          Deprecated. Set the HTTP request method
 void setServer(java.lang.String newServerName)
          Deprecated. Change the server name for the URL in this request, but leave everything else unaffected.
 void setUrl(java.lang.String u)
          Deprecated. Set the HTTP request URL
 void writeRequest(RequestEvent e)
          Deprecated. Write the HTTP request into the MegOutputStream associated with the given RequestEvent.
 
Methods inherited from class com.ibm.wbi.protocol.http.HttpBase
add, change, get, getAll, getContent, getContentLength, getContentType, getKeys, getProtocolVersion, initialize, remove, remove, removeAll, set, setContent, setContentLength, setContentType, setProtocolVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
Deprecated. 

rheader

protected HttpRequestHeader rheader
Deprecated. 
Constructor Detail

HttpRequest

public HttpRequest()
Deprecated. 
Construct a default HTTP 1.0 request, which is a "GET" of "http://www.ibm.com" with no other header information.

HttpRequest

public HttpRequest(ResponseToRequest rtr,
                   boolean loadContent)
Deprecated. 
Construct an HTTP 1.0 request from the request in the given MegInputStream.
Parameters:
rtr - The ResponseToRequest containing the original HTTP request (RequestEvent and ServiceResult implement that interface).
loadContent - If true, the request content (if any) is loaded and made available through the getContent() method.

HttpRequest

public HttpRequest(java.lang.String request)
Deprecated. 
Construct an HTTP 1.0 request from a request String. The String should contain something of the form:
   GET http://www.ibm.com/ HTTP/1.0 \r\n
   accept-type:  text/html \r\n
   \r\n
 
Parameters:
request - the HTTP 1.0 request String

HttpRequest

public HttpRequest(HttpRequestHeader request)
Deprecated. 
Method Detail

setMethod

public void setMethod(java.lang.String m)
Deprecated. 
Set the HTTP request method
Parameters:
m - The request method (e.g. "GET", "PUT", "POST", etc.)

setUrl

public void setUrl(java.lang.String u)
Deprecated. 
Set the HTTP request URL
Parameters:
u - The requested URL, can be either of proxy form (e.g. "http://www.ibm.com") or server form (e.g. "/foo/bar.html")

getMethod

public java.lang.String getMethod()
Deprecated. 
Access the HTTP request method.
Returns:
The request method (e.g. "GET", "PUT", "POST", etc.)

getUrl

public java.lang.String getUrl()
Deprecated. 
Access the HTTP request URL.
Returns:
The request url.

getCookies

public java.util.Properties getCookies()
Deprecated. 
Access the cookies that are being passed to the server with this request.
Returns:
The cookies are returnd as name/value pairs within a Properties object.

getCookie

public java.lang.String getCookie(java.lang.String name)
Deprecated. 
Inefficient for accessing multiple cookies!
Parameters:
name - The cookie.
Returns:
null if no value for this name.
See Also:
getCookies()

produceRequestWithoutContent

public java.lang.String produceRequestWithoutContent()
Deprecated. 
Produces request header up through the double \r\n, but excludes any request content (e.g. for POST requests)
Returns:
The HTTP request string.

produceRequestWithContent

public java.lang.String produceRequestWithContent()
Deprecated. 
Produces request header up through the double \r\n, plus any request content
Returns:
The HTTP request string.

writeRequest

public void writeRequest(RequestEvent e)
Deprecated. 
Write the HTTP request into the MegOutputStream associated with the given RequestEvent.
Parameters:
e - The RequestEvent to which the HTTP request should be written (usually the one that was given to your RequestEditor.handleRequest() method)

parseRequestHeader

public void parseRequestHeader(java.lang.String request)
Deprecated. 
Parse the HTTP request that is contained in the given String and set the properties in this object to correspond to that request.
Parameters:
request - The request to parse.

loadRequestContent

public void loadRequestContent(ResponseToRequest rtr)
Deprecated. 
Load the request contents that are in the given MegInputStream. The contents are loaded and stored in the Content property of this HttpRequest object. The "content-length" header field is also set appropriately. This operation consumes memory corresponding to the size of the request content (which may be arbitrarily large) -- so be careful.
Parameters:
rtr - The ResponseToRequest (RequestEvent or ServiceResult)

addQueryTerm

public void addQueryTerm(java.lang.String key,
                         java.lang.String value)
Deprecated. 
Add a term to the query portion of the request (following a '?' in a "GET" request). This method allows the easy management of CGI forms and similar requests. For example, if the request is to "GET" the URL "/foo/bar.html" and we add a QueryTerm with key "name" and value "Rob Barrett" then the new request will be "GET /foo/bar.html?name=Rob_Barrett".
Parameters:
key - The attribute name for the query term
value - The attribute value for the query term

setServer

public void setServer(java.lang.String newServerName)
Deprecated. 
Change the server name for the URL in this request, but leave everything else unaffected. For example, if the request is for a URL: "http://www.ibm.com/foo?a=b" and this method is invoked with a parameter "java.com" then the request will be for "http://java.ibm.com/foo?a=b". This is useful for server redirects.
Parameters:
newServerName - The name of the new server to which the request should be aimed

produceURLObject

public java.net.URL produceURLObject()
Deprecated. 
Converts the requested URL into a URL object.
Returns:
The requested URL

getPathFromFile

public static java.lang.String getPathFromFile(java.net.URL u)
Deprecated. 
Return the path portion of the given URL, without the protocol, the server, or the query portion. (this method is convenient since the URL class returns the path PLUS QUERY)
Parameters:
u - The URL to parse.
Returns:
The path portion of the URL. If the URL is "http://www.ibm.com/foo/bar.html?a=b", then this returns "/foo/bar.html"

getQueryFromFile

public static java.lang.String getQueryFromFile(java.net.URL u)
Deprecated. 
Return the query portion of the given URL, without the protocol, the server, or the file portion. (this method is convenient since the URL class returns the path PLUS QUERY)
Parameters:
u - The URL to parse.
Returns:
The query portion of the URL. If the URL is "http://www.ibm.com/foo/bar.html?a=b", then this returns "a=b".

main

public static void main(java.lang.String[] args)
Deprecated. 
Test Driver.
Parameters:
args - Command line arguments.