rabbit.http
Class HttpHeaderWithContent

java.lang.Object
  extended by rabbit.http.GeneralHeader
      extended by rabbit.http.HttpHeader
          extended by rabbit.http.HttpHeaderWithContent
All Implemented Interfaces:
Iterable<Header>, Storable

public class HttpHeaderWithContent
extends HttpHeader

A http header with some predefined content

Author:
Robert Olofsson

Field Summary
 
Fields inherited from class rabbit.http.GeneralHeader
headers
 
Constructor Summary
HttpHeaderWithContent()
          Create a new HTTPHeader from scratch
 
Method Summary
protected  void fillBuffer(StringBuilder sb)
          Fill the given StringBuilder with text from this header.
 byte[] getBytes()
          Convert this header to a byte[].
 byte[] getContent()
          Get the current content for this request/response.
 void setContent(byte[] content)
          Set the Content for the request/response Mostly not used for responses.
 void setContent(String data, String charset)
          Set the Content for the request/response Mostly not used for responses.
 
Methods inherited from class rabbit.http.HttpHeader
equals, getHTTPVersion, getMethod, getReasonPhrase, getRequestLine, getRequestURI, getResponseHTTPVersion, getStatusCode, getStatusLine, hashCode, isDot9Request, isHeadOnlyRequest, isRequest, isResponse, isSecure, isSSLRequest, read, setHTTPVersion, setMehtod, setReasonPhrase, setRequestLine, setRequestURI, setResponseHTTPVersion, setStatusCode, setStatusLine, write
 
Methods inherited from class rabbit.http.GeneralHeader
addHeader, addHeader, copyHeader, getHeader, getHeaders, iterator, removeHeader, removeValue, setExistingValue, setHeader, size, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpHeaderWithContent

public HttpHeaderWithContent()
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 HttpHeader
Parameters:
sb - the StringBuilder this header is written to

getBytes

public byte[] getBytes()
Description copied from class: HttpHeader
Convert this header to a byte[]. The header lines are converted to US-ASCII and any content is appended.

Overrides:
getBytes in class HttpHeader
Returns:
the content of this header

setContent

public void setContent(byte[] 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.

setContent

public void setContent(String data,
                       String charset)
Set the Content for the request/response Mostly not used for responses. As a side effect the "Content-Length" header is also set.

Parameters:
data - the String to set
charset - the character encoding to use when converting the string to bytes
Throws:
IllegalArgumentException - if the charset is unknown

getContent

public byte[] getContent()
Description copied from class: HttpHeader
Get the current content for this request/response.

Overrides:
getContent in class HttpHeader
Returns:
the resource associated with this header, may be null