prupp
Class HTTPHeader

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

public class HTTPHeader
extends java.lang.Object

Reads in a http-header (either a response or a request) and sets up for some nice handling of the header.


Constructor Summary
HTTPHeader()
          Create a new HTTPHeader from scratch
HTTPHeader(java.io.DataInputStream in)
          Read in a HTTPHeader from an inputstream.
 
Method Summary
 java.lang.String getHeader(java.lang.String type)
          get the value of header type
 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 getReasonPhrase()
          Get the Reason phrase of the response (only valid for responses).
 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).
 java.lang.String getStatusline()
          Get the statusline of this header (only valid for responses).
 boolean isHeadOnlyRequest()
          Is this request for the head only?
 void removeHeader(java.lang.String type)
          removes a headerline from this header
 void setHeader(java.lang.String type, java.lang.String value)
          Set or replaces a value for given type.
 void setHTTPVersion(java.lang.String version)
          Set the HTTP Version to use for request.
 void setMehtod(java.lang.String method)
          Sets the request method of this header
 void setReasonPhrase(java.lang.String reason)
          Set the reason phrase for this reqponse.
 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 setResponseHTTPVersion(java.lang.String httpVersion)
          Set the HTTP version for this response.
 void setStatusCode(java.lang.String status)
          Set the Status code for this response.
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HTTPHeader

public HTTPHeader()
Create a new HTTPHeader from scratch

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.
Method Detail

toString

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

getHeader

public java.lang.String getHeader(java.lang.String type)
get the value of header type
Parameters:
type - the Header were intrested in.
Returns:
the value of type or null if no value is set.

setHeader

public void setHeader(java.lang.String type,
                      java.lang.String value)
Set or replaces a value for given type.
Parameters:
type - the type or category that we want to set.
value - the value we want to set

removeHeader

public void removeHeader(java.lang.String type)
removes a headerline from this header
Parameters:
type - the type we want to remove

getStatusline

public java.lang.String getStatusline()
Get the statusline of this header (only valid for responses).
Returns:
the status of the request.

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)

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.

setMehtod

public void setMehtod(java.lang.String method)
Sets the request method of this header
Parameters:
method - the new requestmethod

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.

setHTTPVersion

public void setHTTPVersion(java.lang.String version)
Set the HTTP Version to use for request.
Parameters:
version - the version to use.

getResponseHTTPVersion

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

setResponseHTTPVersion

public void setResponseHTTPVersion(java.lang.String httpVersion)
Set the HTTP version for this response.
Parameters:
httpVersion - the version to use.

getStatusCode

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

setStatusCode

public void setStatusCode(java.lang.String status)
Set the Status code for this response.
Parameters:
status - the new status code.

getReasonPhrase

public java.lang.String getReasonPhrase()
Get the Reason phrase of the response (only valid for responses).
Returns:
the reason phrase.

setReasonPhrase

public void setReasonPhrase(java.lang.String reason)
Set the reason phrase for this reqponse.
Parameters:
reason - the new reasonphrase