com.ibm.wbi.protocol.http
Class HttpRequestHeader

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

public class HttpRequestHeader
extends HttpHeaderAscii

Class to describe a request header -- this is the header the client (browser) sends the the server (wbi RequestEditor, Generator or WWW server). The interface is (hopefully) more intuitive than the deprecated HttpRequest: you can change fields directly and see the changes instead of having to call produceRequestWithoutContent() and docInfo.setRequestHeader().

See Also:
DocumentInfo, HttpHeaderAscii

Field Summary
protected static java.lang.String DEFAULT_METHOD
           
protected static java.lang.String DEFAULT_URL
           
protected  java.lang.String method
           
protected  boolean othersOk
           
protected  java.lang.String path
           
protected  java.lang.String port
           
protected  java.lang.String protocol
           
protected  java.lang.String query
           
protected  java.lang.String server
           
protected  java.lang.String url
           
protected  boolean urlOk
           
 
Fields inherited from class com.ibm.wbi.protocol.http.HttpHeaderAscii
httpVersion, mime, stamp
 
Constructor Summary
HttpRequestHeader()
          Creates a new HttpRequestHeader instance.
HttpRequestHeader(byte[] h)
          Creates a new HttpRequestHeader instance based on the specified bytes representing ASCII characters.
HttpRequestHeader(byte[] h, int offset, int length)
          Creates a new HttpRequestHeader instance based on the specified bytes representing ASCII characters.
HttpRequestHeader(HttpRequestHeader old)
          Creates a new HttpRequestHeader instance based on the specified exisiting HttpRequestHeader.
HttpRequestHeader(MimeHeaderAscii m)
          Creates a new HttpRequestHeader instance based on the specified MimeHeaderAscii.
HttpRequestHeader(java.lang.String s)
          Creates a new HttpRequestHeader instance based on the specified String.
 
Method Summary
 byte[] asciiGetBytes(boolean rewriteForServer)
          Return a textual representation of this HttpRequestHeader.
 java.lang.Object clone()
          Return a clone of this HttpRequestHeader.
 java.lang.String getMethod()
          Get the HTTP method (e.g., "GET", "PUT", "POST").
 java.lang.String getPath()
          Get the path from the request URL, e.g., "/index.html".
 java.lang.String getPort()
          Get the port from the request URL, e.g., "80".
 java.lang.String getProtocol()
          Get the protocol portion of the request URL, e.g., "http", "ftp", etc.
 java.lang.String getQuery()
          Get the query portion of the request URL, e.g., "?xxx=yyy&z=a".
 java.lang.String getServer()
          Get the server portion of the request URL, e.g., "www.almaden.ibm.com".
 java.lang.String getUrl()
          Get the entire URL requested in the header.
protected  void parseFirstLine(java.lang.String line)
           
protected  void parseUrl()
           
 void setMethod(java.lang.String s)
          Set the HTTP method.
 void setPath(java.lang.String s)
          Set the path in the request URL.
 void setPort(java.lang.String s)
          Set the port in the request URL.
 void setProtocol(java.lang.String s)
          Set the protocol portion of the request URL.
 void setQuery(java.lang.String s)
          Set the query portion of the request URL.
 void setServer(java.lang.String s)
          Set the server portion of the request URL.
 void setServer(java.lang.String s, boolean setHostField)
          Set the server portion of the request URL.
 void setUrl(java.lang.String s)
          Set the entire URL requested in the header.
 java.lang.String toString()
          Return a textual representation of this HttpRequestHeader.
 java.lang.String toString(boolean rewriteForServer)
          Return a textual representation of this HttpRequestHeader.
protected  java.lang.String urlString()
           
 
Methods inherited from class com.ibm.wbi.protocol.http.HttpHeaderAscii
add, add, copyMimeHeader, get, getAll, getMimeHeaderString, getRaw, getVersion, keys, parseAllHeaderFields, parseAllSplitHeaderFields, parseAllSplitHeaderFields, parseHeader, parseHeaderField, remove, set, set, setVersion, stamp, stamped
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

method

protected java.lang.String method

url

protected java.lang.String url

urlOk

protected boolean urlOk

protocol

protected java.lang.String protocol

server

protected java.lang.String server

path

protected java.lang.String path

port

protected java.lang.String port

query

protected java.lang.String query

othersOk

protected boolean othersOk

DEFAULT_METHOD

protected static final java.lang.String DEFAULT_METHOD

DEFAULT_URL

protected static final java.lang.String DEFAULT_URL
Constructor Detail

HttpRequestHeader

public HttpRequestHeader()
Creates a new HttpRequestHeader instance.

HttpRequestHeader

public HttpRequestHeader(MimeHeaderAscii m)
Creates a new HttpRequestHeader instance based on the specified MimeHeaderAscii.
Parameters:
m - a MimeHeaderAscii value

HttpRequestHeader

public HttpRequestHeader(byte[] h)
                  throws MalformedHeaderException
Creates a new HttpRequestHeader instance based on the specified bytes representing ASCII characters.
Parameters:
h - The array containing the bytes.

HttpRequestHeader

public HttpRequestHeader(byte[] h,
                         int offset,
                         int length)
                  throws MalformedHeaderException
Creates a new HttpRequestHeader instance based on the specified bytes representing ASCII characters.
Parameters:
h - The array containing the bytes.
offset - The offset within the array where the bytes start.
length - The length of the bytes within the array.

HttpRequestHeader

public HttpRequestHeader(java.lang.String s)
                  throws MalformedHeaderException
Creates a new HttpRequestHeader instance based on the specified String.
Parameters:
s - The string containing the header text.

HttpRequestHeader

public HttpRequestHeader(HttpRequestHeader old)
Creates a new HttpRequestHeader instance based on the specified exisiting HttpRequestHeader.
Parameters:
old - The existing HttpRequestHeader.
Method Detail

clone

public java.lang.Object clone()
Return a clone of this HttpRequestHeader.
Overrides:
clone in class java.lang.Object
Returns:
The clone.

toString

public java.lang.String toString()
Return a textual representation of this HttpRequestHeader.
Overrides:
toString in class HttpHeaderAscii
Returns:
The header as a String.

toString

public java.lang.String toString(boolean rewriteForServer)
Return a textual representation of this HttpRequestHeader.
Parameters:
rewriteForServer - If true, the first line of the header will be modified from proxy form to server form. E.g., "GET http://www.almaden.ibm.com/index.html HTTP/1.0" becomes "GET /index.html HTTP/1.0".
Returns:
The header as a String.

asciiGetBytes

public byte[] asciiGetBytes(boolean rewriteForServer)
Return a textual representation of this HttpRequestHeader.
Parameters:
rewriteForServer - If true, the first line of the header will be modified from proxy form to server form. E.g., "GET http://www.almaden.ibm.com/index.html HTTP/1.0" becomes "GET /index.html HTTP/1.0".
Returns:
The header as bytes encoded using US-ASCII.

getMethod

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

setMethod

public void setMethod(java.lang.String s)
Set the HTTP method.
Parameters:
The - HTTP method.

getUrl

public java.lang.String getUrl()
Get the entire URL requested in the header.
Returns:
The URL.

setUrl

public void setUrl(java.lang.String s)
Set the entire URL requested in the header. As a side effect, this will set the "Host:" header field to the server name specified in the URL.
Parameters:
s - The new URL.

getProtocol

public java.lang.String getProtocol()
Get the protocol portion of the request URL, e.g., "http", "ftp", etc.
Returns:
The protocol.

setProtocol

public void setProtocol(java.lang.String s)
Set the protocol portion of the request URL.
Parameters:
s - The protocol.

getServer

public java.lang.String getServer()
Get the server portion of the request URL, e.g., "www.almaden.ibm.com".
Returns:
The server.

setServer

public void setServer(java.lang.String s)
Set the server portion of the request URL. As a side effect, this will set the "Host:" header field to the specified server.
Parameters:
s - The server.

setServer

public void setServer(java.lang.String s,
                      boolean setHostField)
Set the server portion of the request URL. As a side effect, this will set the "Host:" header field to the specified server.
Parameters:
s - The server.
setHostField - Whether to update the "Host:" field of the header correspondingly.

getPath

public java.lang.String getPath()
Get the path from the request URL, e.g., "/index.html".
Returns:
The path.

setPath

public void setPath(java.lang.String s)
Set the path in the request URL.
Parameters:
s - The path.

getPort

public java.lang.String getPort()
Get the port from the request URL, e.g., "80".
Returns:
The port.

setPort

public void setPort(java.lang.String s)
Set the port in the request URL.
Parameters:
s - The port.

getQuery

public java.lang.String getQuery()
Get the query portion of the request URL, e.g., "?xxx=yyy&z=a".
Returns:
The query.

setQuery

public void setQuery(java.lang.String s)
Set the query portion of the request URL.
Parameters:
s - The query.

urlString

protected java.lang.String urlString()

parseUrl

protected void parseUrl()

parseFirstLine

protected void parseFirstLine(java.lang.String line)
                       throws MalformedHeaderException
Overrides:
parseFirstLine in class HttpHeaderAscii