com.ibm.wbi.protocol.http
Class HttpHeader

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

public final class HttpHeader
extends java.lang.Object

HttpHeader is an object that aides in the creation of a response header. Generators are responsible for the creation of a response header during the act of satisfying a request. Normally this header is returned from a web server (if the default generator is used). Generators that satisify a request without going to a server can use this object to create a properly formatted response header.

HttpHeader does support creating headers with multiple keys of the same name.


Field Summary
static java.lang.String ACCEPT
           
static java.lang.String CONTENT_ENCODING
           
static java.lang.String CONTENT_LANGUAGE
           
static java.lang.String CONTENT_LENGTH
           
static java.lang.String CONTENT_TYPE
           
static java.lang.String COPYRIGHT
           
static java.lang.String PVC_DEVICE_TYPE
           
static java.lang.String PVC_NETWORK_TYPE
           
static java.lang.String PVC_SESSION
           
static java.lang.String PVC_USER
           
static java.lang.String USER_AGENT
           
static java.lang.String USER_AGENT_COLOR
           
static java.lang.String USER_AGENT_PIXELS
           
static java.lang.String WTP
           
 
Constructor Summary
HttpHeader()
          A constructor that creates an empty HttpHeader object.
HttpHeader(int contentLength, java.lang.String server, java.lang.String contentType, boolean nocache)
          A constructor that creates a new HttpHeader object with the passed values used as initial settings.
HttpHeader(java.lang.String server)
          A constructor that creates a new HttpHeader object with the passed server as its initial value.
HttpHeader(SystemContext sct)
          A constructor that creates an empty HttpHeader object.
 
Method Summary
 void add(java.lang.String name, java.lang.String value)
          Adds a name/value pair to the MIME data when the header is generated.
 java.lang.String getHeader()
          Causes a correctly formatted header to be generated.
 int length()
          Returns the length, in characters, of the current header.
static void main(java.lang.String[] args)
          Test driver.
 void remove(java.lang.String name)
          Removes a name(s) (or keyword) from the current set of MIME keywords.
 void setContentLanguage(java.lang.String language)
          Sets the content language (MIME Content-Language:) value in the current HttpHeader object.
 void setContentLength(int length)
          Sets the content length (MIME Content-Length:) value in the current HttpHeader object.
 void setContentType(java.lang.String type)
          Sets the content type (MIME Content-Type:) value in the current HttpHeader object.
 void setNoCache()
          Requests that the object remove the appropriate MIME data with regard to cache requests.
 void setNoCache(boolean noCache)
          Requests that the object insert or remove the appropriate MIME data with regard to cache requests.
 void setResponseCode(int code)
          Sets the response code in the current HttpHeader object.
 void setResponseCode(int code, java.lang.String msg)
          Sets the response code and response message in the current HttpHeader object.
 void setResponseMessage(java.lang.String msg)
          Sets the response message in the current HttpHeader object.
 void setServer(java.lang.String server)
          Sets the server value in the current HttpHeader object.
 java.lang.String toString()
          Causes a correctly formatted header to be generated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT

ACCEPT

public static final java.lang.String ACCEPT

CONTENT_ENCODING

public static final java.lang.String CONTENT_ENCODING

CONTENT_LANGUAGE

public static final java.lang.String CONTENT_LANGUAGE

CONTENT_LENGTH

public static final java.lang.String CONTENT_LENGTH

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE

USER_AGENT

public static final java.lang.String USER_AGENT

USER_AGENT_COLOR

public static final java.lang.String USER_AGENT_COLOR

USER_AGENT_PIXELS

public static final java.lang.String USER_AGENT_PIXELS

PVC_SESSION

public static final java.lang.String PVC_SESSION

PVC_DEVICE_TYPE

public static final java.lang.String PVC_DEVICE_TYPE

PVC_NETWORK_TYPE

public static final java.lang.String PVC_NETWORK_TYPE

PVC_USER

public static final java.lang.String PVC_USER

WTP

public static final java.lang.String WTP
Constructor Detail

HttpHeader

public HttpHeader(int contentLength,
                  java.lang.String server,
                  java.lang.String contentType,
                  boolean nocache)
A constructor that creates a new HttpHeader object with the passed values used as initial settings.
Parameters:
contentLength - The MIME content-length: setting.
server - The server to associate with the response.
contentType - The MIME content-type: setting.
nocache - The MIME data should include the appropriate request to not cache this response if true.

HttpHeader

public HttpHeader(java.lang.String server)
A constructor that creates a new HttpHeader object with the passed server as its initial value. By default, no caching is requested.
Parameters:
server - The server to associate with the response.

HttpHeader

public HttpHeader(SystemContext sct)
A constructor that creates an empty HttpHeader object. By default, no caching is requested.
Parameters:
sct - The SystemContext to retrieve the server from.

HttpHeader

public HttpHeader()
A constructor that creates an empty HttpHeader object. By default, no caching is requested.
Method Detail

setContentLength

public void setContentLength(int length)
Sets the content length (MIME Content-Length:) value in the current HttpHeader object.
Parameters:
length - The inbound content length.

setContentLanguage

public void setContentLanguage(java.lang.String language)
Sets the content language (MIME Content-Language:) value in the current HttpHeader object.
Parameters:
language - The inbound content language.

setContentType

public void setContentType(java.lang.String type)
Sets the content type (MIME Content-Type:) value in the current HttpHeader object.
Parameters:
type - The inbound content type.

setNoCache

public void setNoCache(boolean noCache)
Requests that the object insert or remove the appropriate MIME data with regard to cache requests. If set to true, the HttpHeader object will add entries to the MIME data that request that the object not be cached. Setting the value to false will remove these settings. These settings are a request to the browser to prevent caching of the returned page. The browser implementation may choose to ignore the request.
Parameters:
noCache - Sets the current object's no-cache state.

setNoCache

public void setNoCache()
Requests that the object remove the appropriate MIME data with regard to cache requests. The HttpHeader object will add entries to the MIME data that request that the object not be cached. These settings are a request to the browser to prevent caching of the returned page. The browser implementation may choose to ignore the request.

setServer

public void setServer(java.lang.String server)
Sets the server value in the current HttpHeader object.
Parameters:
server - The inbound server to be used.

setResponseMessage

public void setResponseMessage(java.lang.String msg)
Sets the response message in the current HttpHeader object. The response message occurs after response code in an Http response data stream. By default, this message is set to "OK".
Parameters:
msg - The inbound message to be used.

setResponseCode

public void setResponseCode(int code,
                            java.lang.String msg)
Sets the response code and response message in the current HttpHeader object. The code generally reflects the return code issued from the web server. By default, this code is set to 200. The response message occurs after the response code in the Http response message. By default, this message is set to "OK".
Parameters:
code - The response code to be used.
msg - The message to be used.

setResponseCode

public void setResponseCode(int code)
Sets the response code in the current HttpHeader object. The code generally reflects the return code issued from the web server. By default, this code is set to 200.
Parameters:
code - The response code to be used.

add

public void add(java.lang.String name,
                java.lang.String value)
Adds a name/value pair to the MIME data when the header is generated.
Parameters:
name - The new name (or keyword) to be added.
value - The value to be associated with the name.

remove

public void remove(java.lang.String name)
Removes a name(s) (or keyword) from the current set of MIME keywords. The case of the provided name must exactly match the case of the name to be removed.
Parameters:
name - The new name (or keyword) to be removed.

toString

public java.lang.String toString()
Causes a correctly formatted header to be generated.
Overrides:
toString in class java.lang.Object

getHeader

public java.lang.String getHeader()
Causes a correctly formatted header to be generated.
Returns:
A formatted header.

length

public int length()
Returns the length, in characters, of the current header.
Returns:
The length, in characters, of the current header.

main

public static void main(java.lang.String[] args)
Test driver.
Parameters:
args - The arguments.