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: 2088 $, $Date: 2010-01-27 11:38:17 +0900 (Wed, 27 Jan 2010) $
Author:
The Netty Project, Andy Taylor (andy.taylor@jboss.org), Trustin Lee
See Also:
HttpHeaders

Method Summary
 void addHeader(String name, Object 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()
          Deprecated. Use HttpHeaders.getContentLength(HttpMessage) instead.
 long getContentLength(long defaultValue)
          Deprecated. Use HttpHeaders.getContentLength(HttpMessage, long) instead.
 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<Map.Entry<String,String>> getHeaders()
          Returns the all header names and values 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 this message does not have any content but the HttpChunks, which is generated by HttpMessageDecoder consecutively, contain the actual content.
 boolean isKeepAlive()
          Deprecated. Use HttpHeaders.isKeepAlive(HttpMessage) instead.
 void removeHeader(String name)
          Removes the header with the specified name.
 void setChunked(boolean chunked)
          Sets if this message does not have any content but the HttpChunks, which is generated by HttpMessageDecoder consecutively, contain the actual content.
 void setContent(ChannelBuffer content)
          Sets the content of this message.
 void setHeader(String name, Iterable<?> values)
          Sets a new header with the specified name and values.
 void setHeader(String name, Object value)
          Sets a new header with the specified name and value.
 void setProtocolVersion(HttpVersion version)
          Sets the protocol version of this message.
 

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.

getHeaders

List<Map.Entry<String,String>> getHeaders()
Returns the all header names and values that this message contains.

Returns:
the List of the header name-value pairs. An empty list if there is no header in this message.

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.


setProtocolVersion

void setProtocolVersion(HttpVersion version)
Sets the protocol version of this message.


getContent

ChannelBuffer getContent()
Returns the content of this message. If there is no content or isChunked() returns true, 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,
               Object value)
Adds a new header with the specified name and value.


setHeader

void setHeader(String name,
               Object 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<?> 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

@Deprecated
long getContentLength()
Deprecated. Use HttpHeaders.getContentLength(HttpMessage) instead.


getContentLength

@Deprecated
long getContentLength(long defaultValue)
Deprecated. Use HttpHeaders.getContentLength(HttpMessage, long) instead.


isChunked

boolean isChunked()
Returns true if and only if this message does not have any content but the HttpChunks, which is generated by HttpMessageDecoder consecutively, contain the actual content.

Please note that this method will keep returning true if the "Transfer-Encoding" of this message is "chunked", even if you attempt to override this property by calling setChunked(boolean) with false.


setChunked

void setChunked(boolean chunked)
Sets if this message does not have any content but the HttpChunks, which is generated by HttpMessageDecoder consecutively, contain the actual content.

If this method is called with true, the content of this message becomes ChannelBuffers.EMPTY_BUFFER.

Even if this method is called with false, isChunked() will keep returning true if the "Transfer-Encoding" of this message is "chunked".


isKeepAlive

@Deprecated
boolean isKeepAlive()
Deprecated. Use HttpHeaders.isKeepAlive(HttpMessage) instead.



Copyright © 2008-2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.