rabbit.http
Class HttpHeader

java.lang.Object
  extended by rabbit.http.GeneralHeader
      extended by rabbit.http.HttpHeader
All Implemented Interfaces:
Storable

public class HttpHeader
extends GeneralHeader

A class to handle http headers.

Author:
Robert Olofsson

Field Summary
 
Fields inherited from class rabbit.http.GeneralHeader
headers
 
Constructor Summary
HttpHeader()
          Create a new HTTPHeader from scratch
 
Method Summary
 boolean equals(Object o)
          Is this Header equal to the other object?
protected  void fillBuffer(StringBuilder sb)
          Fill the given StringBuilder with text from this header.
 String getContent()
          Get the current content for this request/response.
 String getHTTPVersion()
          Get the HTTP Version of this request (only valid for requests).
 String getMethod()
          Get the request method of this header (only valid for requests).
 String getReasonPhrase()
          Get the Reason phrase of the response (only valid for responses).
 String getRequestLine()
          Get the requestline of this header (only valid for requests).
 String getRequestURI()
          Get the requestURI of this request (only valid for requests).
 String getResponseHTTPVersion()
          Get the HTTP version of the response (only valid for responses).
 String getStatusCode()
          Get the Status code of the response (only valid for responses).
 String getStatusLine()
          Get the statusline of this header (only valid for responses).
 int hashCode()
          Get the hashCode for this header.
 boolean isDot9Request()
          Is this request a HTTP/0.9 type request?
 boolean isHeadOnlyRequest()
          Is this request for the head only?
 boolean isRequest()
          Try to guess if this header is a request.
 boolean isResponse()
          Try to guess if this header is a response.
 boolean isSecure()
          Try to guess if this header is a secure thing.
 boolean isSSLRequest()
          Check to see if this header is an SSL header.
 void read(DataInput in)
          Fill in this object with data from the given input.
 void setContent(String content)
          Set the Content for the request/response Mostly not used for responses.
 void setHTTPVersion(String version)
          Set the HTTP Version to use for request.
 void setMehtod(String method)
          Sets the request method of this header
 void setReasonPhrase(String reason)
          Set the reason phrase for this reqponse.
 void setRequestLine(String line)
          Set the requestline of this header
 void setRequestURI(String requestURI)
          Sets the request URI of this header
 void setResponseHTTPVersion(String httpVersion)
          Set the HTTP version for this response.
 void setStatusCode(String status)
          Set the Status code for this response.
 void setStatusLine(String line)
          Set the statusline of this header.
 void write(DataOutput out)
          Write this object to the given output.
 
Methods inherited from class rabbit.http.GeneralHeader
addHeader, addHeader, copyHeader, getHeader, getHeaders, removeHeader, removeValue, setExistingValue, setHeader, size, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpHeader

public HttpHeader()
Create a new HTTPHeader from scratch

Method Detail

fillBuffer

protected void fillBuffer(StringBuilder sb)
Description copied from class: GeneralHeader
Fill the given StringBuilder with text from this header.

Overrides:
fillBuffer in class GeneralHeader

getStatusLine

public String getStatusLine()
Get the statusline of this header (only valid for responses).

Returns:
the status of the request.

setStatusLine

public void setStatusLine(String line)
Set the statusline of this header.

Parameters:
line - a Status-Line )RFC 2068: 6.1)

getRequestLine

public String getRequestLine()
Get the requestline of this header (only valid for requests).

Returns:
the request.

setRequestLine

public void setRequestLine(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 String getMethod()
Get the request method of this header (only valid for requests).

Returns:
the request method.

setMehtod

public void setMehtod(String method)
Sets the request method of this header

Parameters:
method - the new requestmethod

isSSLRequest

public boolean isSSLRequest()
Check to see if this header is an SSL header.

Returns:
true if this header is an CONNECT request.

getRequestURI

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

Returns:
the requestURI.

setRequestURI

public void setRequestURI(String requestURI)
Sets the request URI of this header

Parameters:
requestURI - the new URI

getHTTPVersion

public String getHTTPVersion()
Get the HTTP Version of this request (only valid for requests).

Returns:
the http version.

setHTTPVersion

public void setHTTPVersion(String version)
Set the HTTP Version to use for request.

Parameters:
version - the version to use.

getResponseHTTPVersion

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

Returns:
the HTTP version.

setResponseHTTPVersion

public void setResponseHTTPVersion(String httpVersion)
Set the HTTP version for this response.

Parameters:
httpVersion - the version to use.

getStatusCode

public String getStatusCode()
Get the Status code of the response (only valid for responses).

Returns:
the status code.

setStatusCode

public void setStatusCode(String status)
Set the Status code for this response.

Parameters:
status - the new status code.

getReasonPhrase

public String getReasonPhrase()
Get the Reason phrase of the response (only valid for responses).

Returns:
the reason phrase.

setReasonPhrase

public void setReasonPhrase(String reason)
Set the reason phrase for this reqponse.

Parameters:
reason - the new reasonphrase

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.


hashCode

public int hashCode()
Get the hashCode for this header.

Overrides:
hashCode in class Object
Returns:
the hash code for this object.

equals

public boolean equals(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 Object
Parameters:
o - the Object to compare to.
Returns:
true if o and this object are equal, false otherwise.

isRequest

public boolean isRequest()
Try to guess if this header is a request.

Returns:
true if this (probably) is a request, 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.

isSecure

public boolean isSecure()
Try to guess if this header is a secure thing.

Returns:
true if this (probably) is a secure connection.

setContent

public void setContent(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 String getContent()
Get the current content for this request/response.


read

public void read(DataInput in)
          throws IOException
Description copied from interface: Storable
Fill in this object with data from the given input.

Specified by:
read in interface Storable
Overrides:
read in class GeneralHeader
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Storable
Write this object to the given output.

Specified by:
write in interface Storable
Overrides:
write in class GeneralHeader
Throws:
IOException