com.ibm.wbi.protocol.http
Class HttpResponse

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

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

public class HttpResponse
extends HttpBase

This class is used to manipulate HTTP 1.0 responses. It can be constructed with default values, from a response header string, or from a MegInputStream (that comes from a RequestEvent).

The response can then be manipulated through various properties.

Finally, the response can be produced as a String, or written to the output stream. associated with a RequestEvent. see writeResponse(RequestEvent). HttpResponse does not support creating headers with multiple keys of the same name. For example, if you do two add calls on the same HttpResponse object with the same field name, the second add will override the first.

See Also:
HttpHeaderAscii, HttpRequestHeader, HttpResponseHeader

Field Summary
static java.lang.String COPYRIGHT
          Deprecated.  
protected static java.lang.String DEFAULT_CONTENT_TYPE
          Deprecated.  
protected static java.lang.String DEFAULT_RESPONSE_CODE
          Deprecated.  
protected static java.lang.String DEFAULT_RESPONSE_MESSAGE
          Deprecated.  
protected static java.lang.String DEFAULT_SERVER
          Deprecated.  
protected  HttpResponseHeader rheader
          Deprecated.  
 
Fields inherited from class com.ibm.wbi.protocol.http.HttpBase
content, header
 
Constructor Summary
HttpResponse()
          Deprecated. Construct a default HTTP 1.0 response, which has the default parameters.
HttpResponse(ResponseToRequest rtr, boolean loadContent)
          Deprecated. Construct an HTTP 1.0 response from the given MegInputStream.
HttpResponse(java.lang.String header)
          Deprecated. Construct an HTTP 1.0 response from the given header string.
HttpResponse(SystemContext sct)
          Deprecated. Construct a default HTTP 1.0 response, which has the default parameters.
 
Method Summary
 void addCookie(java.lang.String name, java.lang.String value, java.util.Date expires, java.lang.String domain, java.lang.String path, boolean secure)
          Deprecated. Add a cookie to this response, which will then be stored in the browser.
 int getResponseCode()
          Deprecated. Access the HTTP response code (e.g.
 java.lang.String getResponseText()
          Deprecated. Access the HTTP response text (e.g.
 java.lang.String getServer()
          Deprecated. Access the name of the server that produced the response.
 boolean isCache()
          Deprecated. Access the Cache property.
 void loadResponseContent(ResponseToRequest rtr)
          Deprecated. Load the response content from the given RequestEvent into the Content property of this HTTP Response object.
static void main(java.lang.String[] args)
          Deprecated. Test Driver.
 void parseResponseHeader(java.lang.String h)
          Deprecated. Parse the response header in the given string and set the various properties to reflect its contents.
protected  java.lang.String produceCurrentDate()
          Deprecated. Produce the current date in String format.
 java.lang.String produceHeader()
          Deprecated. Use produceResponseWithoutContent instead.
 java.lang.String produceResponseWithContent()
          Deprecated. Produces response header up through the double \r\n, plus any response content.
 java.lang.String produceResponseWithoutContent()
          Deprecated. Produce the HTTP header in the form of a String.
 void removeContentLength()
          Deprecated. Removes the "content-length" header field.
 void removeWindowTarget()
          Deprecated. Removes the "window-target" header field.
 void setCache(boolean c)
          Deprecated. Set the Cache property, which indicates to the browser whether this page should be cached or not.
 void setResponseCode(int c)
          Deprecated. Set the HTTP response code (e.g.
 void setResponseText(java.lang.String t)
          Deprecated. Set the HTTP response text (e.g.
 void setServer(java.lang.String s)
          Deprecated. Set the name of the server producing the document.
 void writeHeader(RequestEvent e)
          Deprecated. Use writeResponse( RequestEvent e ) instead.
 void writeResponse(RequestEvent e)
          Deprecated. Produce the HTTP header and store it in the MegOutputStream associated with this 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. 

DEFAULT_SERVER

protected static final java.lang.String DEFAULT_SERVER
Deprecated. 

DEFAULT_CONTENT_TYPE

protected static final java.lang.String DEFAULT_CONTENT_TYPE
Deprecated. 

DEFAULT_RESPONSE_CODE

protected static final java.lang.String DEFAULT_RESPONSE_CODE
Deprecated. 

DEFAULT_RESPONSE_MESSAGE

protected static final java.lang.String DEFAULT_RESPONSE_MESSAGE
Deprecated. 

rheader

protected HttpResponseHeader rheader
Deprecated. 
Constructor Detail

HttpResponse

public HttpResponse()
Deprecated. 
Construct a default HTTP 1.0 response, which has the default parameters.

HttpResponse

public HttpResponse(SystemContext sct)
Deprecated. 
Construct a default HTTP 1.0 response, which has the default parameters.
Parameters:
sct - The SystemContext.

HttpResponse

public HttpResponse(ResponseToRequest rtr,
                    boolean loadContent)
Deprecated. 
Construct an HTTP 1.0 response from the given MegInputStream.
Parameters:
rtr - The ResponseToRequest containing the header fields for the response. E.g., ServiceResult or RequestEvent.
loadContent - If true, the content (if any) will be loaded from the input stream and loaded into the Content property of this object. Otherwise, any content will be left in the input stream. Since the content can be arbitrarily large, caution should be exercised to make sure that you don't load too much stuff into memory.

HttpResponse

public HttpResponse(java.lang.String header)
Deprecated. 
Construct an HTTP 1.0 response from the given header string.
Parameters:
header - An HTTP 1.0 response header, such as:
     HTTP/1.0 200 Ok \r\n
     content-length: 500 \r\n
     content-type: text/html \r\n
     \r\n
 
Method Detail

removeContentLength

public void removeContentLength()
Deprecated. 
Removes the "content-length" header field. This operation is useful when the content is being edited and the final length is unknown.

removeWindowTarget

public void removeWindowTarget()
Deprecated. 
Removes the "window-target" header field. The page will be directed to the current window.

setResponseCode

public void setResponseCode(int c)
Deprecated. 
Set the HTTP response code (e.g. 200 [=Ok]).
Parameters:
c - The ResponseCode.

setResponseText

public void setResponseText(java.lang.String t)
Deprecated. 
Set the HTTP response text (e.g. "Ok", "Page Not Found").
Parameters:
t - The ResponseText.

setServer

public void setServer(java.lang.String s)
Deprecated. 
Set the name of the server producing the document.
Parameters:
s - The name of the server.

setCache

public void setCache(boolean c)
Deprecated. 
Set the Cache property, which indicates to the browser whether this page should be cached or not.
Parameters:
c - if true, the browser is allowed to cache the page; if false, the browser should not

isCache

public boolean isCache()
Deprecated. 
Access the Cache property.
Returns:
Cached?
See Also:
setCache(boolean)

addCookie

public void addCookie(java.lang.String name,
                      java.lang.String value,
                      java.util.Date expires,
                      java.lang.String domain,
                      java.lang.String path,
                      boolean secure)
Deprecated. 
Add a cookie to this response, which will then be stored in the browser.
Parameters:
name - Name of the cookie (required)
value - Value of the cookie (required)
expires - When the cookie expires (may be null)
domain - The domain over which the cookie should be sent back to the server (may be null)
path - The path for which the cookie should be sent back to the server (may be null)
secure - If true, the cookie will only be passed back over secure links

getResponseCode

public int getResponseCode()
Deprecated. 
Access the HTTP response code (e.g. 200 [=Ok])
Returns:
The ResponseCode.

getResponseText

public java.lang.String getResponseText()
Deprecated. 
Access the HTTP response text (e.g. "Ok", "Page Not Found")
Returns:
The ResponseText.

getServer

public java.lang.String getServer()
Deprecated. 
Access the name of the server that produced the response.
Returns:
The server.

produceCurrentDate

protected java.lang.String produceCurrentDate()
Deprecated. 
Produce the current date in String format.
Returns:
Current data.

produceResponseWithoutContent

public java.lang.String produceResponseWithoutContent()
Deprecated. 
Produce the HTTP header in the form of a String. Replaces the deprecated method produceHeader().
Returns:
The header.

produceHeader

public java.lang.String produceHeader()
Deprecated. Use produceResponseWithoutContent instead.

Produce the HTTP header in the form of a String.
Returns:
The header.
See Also:
produceResponseWithoutContent()

produceResponseWithContent

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

writeResponse

public void writeResponse(RequestEvent e)
Deprecated. 
Produce the HTTP header and store it in the MegOutputStream associated with this RequestEvent. Replaces the deprecated method writeHeader(...).
Parameters:
e - The request event.

writeHeader

public void writeHeader(RequestEvent e)
Deprecated. Use writeResponse( RequestEvent e ) instead.

Produce the HTTP header and store it in the MegOutputStream associated with this RequestEvent.
Parameters:
e - The request event.
See Also:
writeResponse( RequestEvent )

parseResponseHeader

public void parseResponseHeader(java.lang.String h)
Deprecated. 
Parse the response header in the given string and set the various properties to reflect its contents.
Parameters:
header - The header.

loadResponseContent

public void loadResponseContent(ResponseToRequest rtr)
Deprecated. 
Load the response content from the given RequestEvent into the Content property of this HTTP Response object.
Parameters:
rtr - ResponseToRequest (RequestEvent or ServiceResult)

main

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