org.eclipse.actf.util.httpproxy.core
Interface IHTTPMessage

All Known Subinterfaces:
IHTTPRequestMessage, IHTTPResponseMessage, IHTTPResponsePushbackMessage

public interface IHTTPMessage

A HTTP request/response message.


Field Summary
static char CR
           
static int DEFAULT_INITIAL_BUFFER_SIZE
           
static char HT
           
static int INIT_NUM_HEADERS
           
static char LF
           
static char SP
           
 
Method Summary
 void addTrailingHeader(IHTTPHeader trailer)
          Adds a HTTP trailing header.
 IHTTPHeader getHeader(byte[] name)
          Gets a HTTP header of the specified name.
 byte[] getHeaderAsBytes(byte[] name)
          Gets value of a HTTP header as an array of bytes.
 List<IHTTPHeader> getHeaders()
          Gets all HTTP headers defined in this HTTP message.
 byte[] getHTTPVersionAsBytes()
          Gets the value of HTTP version as an array of bytes.
 String getHTTPVersionAsString()
          Gets the value of HTTP version as a String.
 IMessageBody getMessageBody()
          Gets the body of this HTTP message.
 long getSerial()
           
 long getTid()
          Gets the TID assigned to this message.
 boolean isChunkedEncoding()
          Returns whether the encoding of this message is chunked or not.
 boolean isConnectionToBeClosed()
          Tells that the connection for exchanging this message needs to be closed or not.
 boolean isHTTPVersion1_1()
          Returns whether the HTTP protocol version of this message is 1.1 or not.
 IHTTPHeader removeHeader(byte[] name)
          Removes a HTTP header of the specified name.
 void setChunkedEncoding(boolean isChunked)
          Sets whether this message is in chunked encoding.
 void setConnectionHeader(boolean keepalive)
          Sets "Connection" HTTP header for this message.
 void setHeader(byte[] name, byte[] value)
          Updates value of a HTTP header, or a HTTP header is added if no HTTP header of the specified name is defined.
 void setTid(long tid)
          Sets the TID for this message.
 void write(long timeout, OutputStream out)
          Writes this message (headers and message body) to the specified output stream.
 void writeBody(long timeout, IMessageBody msgBody, OutputStream out)
          Writes the message body to the specified output stream.
 

Field Detail

INIT_NUM_HEADERS

static final int INIT_NUM_HEADERS
See Also:
Constant Field Values

DEFAULT_INITIAL_BUFFER_SIZE

static final int DEFAULT_INITIAL_BUFFER_SIZE
See Also:
Constant Field Values

CR

static final char CR
See Also:
Constant Field Values

LF

static final char LF
See Also:
Constant Field Values

SP

static final char SP
See Also:
Constant Field Values

HT

static final char HT
See Also:
Constant Field Values
Method Detail

getSerial

long getSerial()

getHTTPVersionAsString

String getHTTPVersionAsString()
Gets the value of HTTP version as a String.

Returns:
HTTP version of this HTTP message

getHTTPVersionAsBytes

byte[] getHTTPVersionAsBytes()
Gets the value of HTTP version as an array of bytes.

Returns:
HTTP version of this HTTP message

getMessageBody

IMessageBody getMessageBody()
Gets the body of this HTTP message.

Returns:
body of this HTTP message

getHeaders

List<IHTTPHeader> getHeaders()
Gets all HTTP headers defined in this HTTP message.

Returns:
list of HTTP header objects

removeHeader

IHTTPHeader removeHeader(byte[] name)
Removes a HTTP header of the specified name.

Parameters:
name - name of a HTTP header
Returns:
the removed HTTP header, or null if no such HTTP header was defined

setHeader

void setHeader(byte[] name,
               byte[] value)
Updates value of a HTTP header, or a HTTP header is added if no HTTP header of the specified name is defined.

Parameters:
name - name of HTTP header
value - value of HTTP header

addTrailingHeader

void addTrailingHeader(IHTTPHeader trailer)
Adds a HTTP trailing header.

Parameters:
trailer - a HTTP trailing header

getHeader

IHTTPHeader getHeader(byte[] name)
Gets a HTTP header of the specified name.

Parameters:
name - name of a HTTP header
Returns:
HTTP header of the specified name

getHeaderAsBytes

byte[] getHeaderAsBytes(byte[] name)
Gets value of a HTTP header as an array of bytes.

Parameters:
name - name of a HTTP header
Returns:
value of the HTTP header as an array of bytes

isChunkedEncoding

boolean isChunkedEncoding()
Returns whether the encoding of this message is chunked or not.

Returns:
true if the encoding of this message is chunked.

setChunkedEncoding

void setChunkedEncoding(boolean isChunked)
Sets whether this message is in chunked encoding.

Parameters:
isChunked - whether this message is in chunked encoding

setTid

void setTid(long tid)
Sets the TID for this message. TID is unique long value assigned to each HTTP request.

Parameters:
tid - TID as a long value

getTid

long getTid()
Gets the TID assigned to this message.

Returns:
TID as a long value

writeBody

void writeBody(long timeout,
               IMessageBody msgBody,
               OutputStream out)
               throws IOException,
                      TimeoutException
Writes the message body to the specified output stream.

Parameters:
timeout - number of milliseconds to wait until the write operation is done, or 0 if it does not need to timeout
msgBody - message body to be written
out - an output stream to which the message body is written
Throws:
IOException
TimeoutException - if it failed to write the message body within the specified time

write

void write(long timeout,
           OutputStream out)
           throws IOException,
                  TimeoutException
Writes this message (headers and message body) to the specified output stream.

Parameters:
timeout - number of milliseconds to wait until the write operation is done, or 0 if it does not need to timeout
out - an output stream to which this message is written
Throws:
IOException
TimeoutException - if it failed to write this message within the specified time

isHTTPVersion1_1

boolean isHTTPVersion1_1()
Returns whether the HTTP protocol version of this message is 1.1 or not.

Returns:
true if the HTTP protocol version of this message is 1.1

setConnectionHeader

void setConnectionHeader(boolean keepalive)
Sets "Connection" HTTP header for this message.

Parameters:
keepalive - true to set the value of "Connection" header to "Keep-Alive", false to set the value of "Connection header to "close"
See Also:
IHTTPHeader.CONNECTION

isConnectionToBeClosed

boolean isConnectionToBeClosed()
Tells that the connection for exchanging this message needs to be closed or not.

Returns:
true if the connection needs to be closed, or false if it can be reused for the following messages