org.jboss.netty.handler.codec.http
Interface HttpMessage

All Known Subinterfaces:
HttpRequest, HttpResponse
All Known Implementing Classes:
DefaultHttpMessage, DefaultHttpRequest, DefaultHttpResponse

public interface HttpMessage

An HTTP message which provides common properties for HttpRequest and HttpResponse.

Version:
$Rev: 1685 $, $Date: 2009-08-28 16:15:49 +0900 (금, 28 8 2009) $
Author:
The Netty Project (netty-dev@lists.jboss.org), Andy Taylor (andy.taylor@jboss.org), Trustin Lee (tlee@redhat.com)
See Also:
HttpHeaders

Method Summary
 void addHeader(String name, String value)
          Adds a new header with the specified name and value.
 void clearHeaders()
          Removes all headers from this message.
 boolean containsHeader(String name)
          Returns true if and only if there is a header with the specified header name.
 ChannelBuffer getContent()
          Returns the content of this message.
 long getContentLength()
          Returns the length of the content.
 long getContentLength(long defaultValue)
          Returns the length of the content.
 String getHeader(String name)
          Returns the header value with the specified header name.
 Set<String> getHeaderNames()
          Returns the Set of all header names that this message contains.
 List<String> getHeaders(String name)
          Returns the header values with the specified header name.
 HttpVersion getProtocolVersion()
          Returns the protocol version of this message.
 boolean isChunked()
          Returns true if and only if the "Transfer-Encoding" of this message is "chunked".
 boolean isKeepAlive()
          Returns true if and only if the connection can remain open and thus 'kept alive'.
 void removeHeader(String name)
          Removes the header with the specified name.
 void setContent(ChannelBuffer content)
          Sets the content of this message.
 void setHeader(String name, Iterable<String> values)
          Sets a new header with the specified name and values.
 void setHeader(String name, String value)
          Sets a new header with the specified name and value.
 

Method Detail

getHeader

String getHeader(String name)
Returns the header value with the specified header name. If there are more than one header value for the specified header name, the first value is returned.

Returns:
the header value or null if there is no such header

getHeaders

List<String> getHeaders(String name)
Returns the header values with the specified header name.

Returns:
the List of header values. An empty list if there is no such header.

containsHeader

boolean containsHeader(String name)
Returns true if and only if there is a header with the specified header name.


getHeaderNames

Set<String> getHeaderNames()
Returns the Set of all header names that this message contains.


getProtocolVersion

HttpVersion getProtocolVersion()
Returns the protocol version of this message.


getContent

ChannelBuffer getContent()
Returns the content of this message. If there is no content, an ChannelBuffers.EMPTY_BUFFER is returned.


setContent

void setContent(ChannelBuffer content)
Sets the content of this message. If null is specified, the content of this message will be set to ChannelBuffers.EMPTY_BUFFER.


addHeader

void addHeader(String name,
               String value)
Adds a new header with the specified name and value.


setHeader

void setHeader(String name,
               String value)
Sets a new header with the specified name and value. If there is an existing header with the same name, the existing header is removed.


setHeader

void setHeader(String name,
               Iterable<String> values)
Sets a new header with the specified name and values. If there is an existing header with the same name, the existing header is removed.


removeHeader

void removeHeader(String name)
Removes the header with the specified name.


clearHeaders

void clearHeaders()
Removes all headers from this message.


getContentLength

long getContentLength()
Returns the length of the content. Please note that this value is not retrieved from getContent() but from the "Content-Length" header, and thus they are independent from each other.

Returns:
the content length or 0 if this message does not have the "Content-Length" header

getContentLength

long getContentLength(long defaultValue)
Returns the length of the content. Please note that this value is not retrieved from getContent() but from the "Content-Length" header, and thus they are independent from each other.

Returns:
the content length or defaultValue if this message does not have the "Content-Length" header

isChunked

boolean isChunked()
Returns true if and only if the "Transfer-Encoding" of this message is "chunked".


isKeepAlive

boolean isKeepAlive()
Returns true if and only if the connection can remain open and thus 'kept alive'.



Copyright © 2008-2009 JBoss, by Red Hat. All Rights Reserved.