Class HTTPHeader

java.lang.Object
  |
  +--Header
        |
        +--HTTPHeader

public class HTTPHeader
extends Header

A class to handle a HTTP Header.


Inner classes inherited from class Header
Header.HeaderEntry
 
Field Summary
static java.lang.String HT
           
static java.lang.String SP
           
 
Fields inherited from class Header
CRLF, FIELD_SEPARATOR, hHeaderEntries
 
Constructor Summary
HTTPHeader()
          Create a new empty HTTPHeader
HTTPHeader(java.io.DataInputStream in)
          Read in a HTTPHeader from an inputstream.
 
Method Summary
 boolean equals(java.lang.Object o)
          Is this Header equal to the other object?
 java.lang.String getContent()
          Get the content of the request/response.
 java.lang.String getHTTPVersion()
          Get the HTTP Version of this request (only valid for requests).
 java.lang.String getMethod()
          Get the request method of this header (only valid for requests).
 java.lang.String getRequestLine()
          Get the requestline of this header (only valid for requests).
 java.lang.String getRequestURI()
          Get the requestURI of this request (only valid for requests).
 java.lang.String getResponseHTTPVersion()
          Get the HTTP version of the response (only valid for responses).
 java.lang.String getStatusCode()
          Get the Status code of the response (only valid for responses).
 boolean isDot9Request()
          Is this request a HTTP/0.9 type request?
 boolean isHeadOnlyRequest()
          Is this request for the head only?
 boolean isResponse()
          Try to guess if this header is a response.
 void readHTTPHeader(java.io.DataInputStream in)
          Read a Header in an inputstream.
 void setContent(java.lang.String content)
          Set the Content for the request/response Mostly not used for responses.
 void setRequestLine(java.lang.String line)
          Set the requestline of this header
 void setRequestURI(java.lang.String requestURI)
          Sets the request URI of this header
 void setStatusLine(java.lang.String line)
          Set the statusline of this header.
 java.lang.String toString()
          get the text value of this header
 
Methods inherited from class Header
getHeaderEntryValue, read, read, removeHeaderEntry, setHeaderEntry
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SP

public static final java.lang.String SP

HT

public static final java.lang.String HT
Constructor Detail

HTTPHeader

public HTTPHeader()
Create a new empty HTTPHeader

HTTPHeader

public HTTPHeader(java.io.DataInputStream in)
           throws java.io.IOException
Read in a HTTPHeader from an inputstream.
Parameters:
in - the stream from which this header is read.
Throws:
java.io.IOException - if reading from in results in exceptions.
Method Detail

readHTTPHeader

public void readHTTPHeader(java.io.DataInputStream in)
                    throws java.io.IOException
Read a Header in an inputstream.
Parameters:
in - the stream from which this header is read.
Throws:
java.io.IOException - if reading from in results in exceptions.

toString

public java.lang.String toString()
get the text value of this header
Overrides:
toString in class Header
Returns:
a String describing this HTTP-Header.

setStatusLine

public void setStatusLine(java.lang.String line)
Set the statusline of this header.
Parameters:
line - a Status-Line (RFC 2068: 6.1)

getRequestLine

public java.lang.String getRequestLine()
Get the requestline of this header (only valid for requests).
Returns:
the request.

setRequestLine

public void setRequestLine(java.lang.String line)
Set the requestline of this header
Parameters:
line - a Request-Line (RFC 2068: 5.1) Request-Line = Method SP Request-URI SP HTTP-Version CRLF

isHeadOnlyRequest

public boolean isHeadOnlyRequest()
Is this request for the head only?
Returns:
true if this request is for HEAD, false otherwise

getMethod

public java.lang.String getMethod()
Get the request method of this header (only valid for requests).
Returns:
the request method.

getRequestURI

public java.lang.String getRequestURI()
Get the requestURI of this request (only valid for requests).
Returns:
the requestURI.

setRequestURI

public void setRequestURI(java.lang.String requestURI)
Sets the request URI of this header
Parameters:
method - the new URI

getHTTPVersion

public java.lang.String getHTTPVersion()
Get the HTTP Version of this request (only valid for requests).
Returns:
the http version.

getResponseHTTPVersion

public java.lang.String getResponseHTTPVersion()
Get the HTTP version of the response (only valid for responses).
Returns:
the HTTP version.

getStatusCode

public java.lang.String getStatusCode()
Get the Status code of the response (only valid for responses).
Returns:
the status code.

setContent

public void setContent(java.lang.String content)
Set the Content for the request/response Mostly not used for responses. As a side effect the "Content-Length" header is also set.
Parameters:
content - the binary content.

getContent

public java.lang.String getContent()
Get the content of the request/response.

isDot9Request

public boolean isDot9Request()
Is this request a HTTP/0.9 type request? A 0.9 request doesnt have a full HTTPheader, only a requestline so we need to treat it differently.

equals

public boolean equals(java.lang.Object o)
Is this Header equal to the other object? Two HTTPHeaders are assumed equal if the requesURI's are equal.
Overrides:
equals in class java.lang.Object
Parameters:
o - the Object to compare to.
Returns:
true if o and this object are equal, false otherwise.

isResponse

public boolean isResponse()
Try to guess if this header is a response.
Returns:
true if this (probably) is a response, false otherwise.