org.jboss.netty.handler.codec.http
接口 HttpMessage

所有已知子接口:
HttpRequest, HttpResponse
所有已知实现类:
DefaultHttpMessage, DefaultHttpRequest, DefaultHttpResponse

public interface HttpMessage

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

另请参见:
HttpHeaders

方法摘要
 void addHeader(java.lang.String name, java.lang.Object value)
          Adds a new header with the specified name and value.
 void clearHeaders()
          Removes all headers from this message.
 boolean containsHeader(java.lang.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()
          已过时。 Use HttpHeaders.getContentLength(HttpMessage) instead.
 long getContentLength(long defaultValue)
          已过时。 Use HttpHeaders.getContentLength(HttpMessage, long) instead.
 java.lang.String getHeader(java.lang.String name)
          Returns the header value with the specified header name.
 java.util.Set<java.lang.String> getHeaderNames()
          Returns the Set of all header names that this message contains.
 java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> getHeaders()
          Returns the all header names and values that this message contains.
 java.util.List<java.lang.String> getHeaders(java.lang.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()
          已过时。 Use HttpHeaders.isKeepAlive(HttpMessage) instead.
 void removeHeader(java.lang.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(java.lang.String name, java.lang.Iterable<?> values)
          Sets a new header with the specified name and values.
 void setHeader(java.lang.String name, java.lang.Object value)
          Sets a new header with the specified name and value.
 void setProtocolVersion(HttpVersion version)
          Sets the protocol version of this message.
 

方法详细信息

getHeader

java.lang.String getHeader(java.lang.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.

返回:
the header value or null if there is no such header

getHeaders

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

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

getHeaders

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

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

containsHeader

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


getHeaderNames

java.util.Set<java.lang.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(java.lang.String name,
               java.lang.Object value)
Adds a new header with the specified name and value.


setHeader

void setHeader(java.lang.String name,
               java.lang.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(java.lang.String name,
               java.lang.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(java.lang.String name)
Removes the header with the specified name.


clearHeaders

void clearHeaders()
Removes all headers from this message.


getContentLength

@Deprecated
long getContentLength()
已过时。 Use HttpHeaders.getContentLength(HttpMessage) instead.


getContentLength

@Deprecated
long getContentLength(long defaultValue)
已过时。 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()
已过时。 Use HttpHeaders.isKeepAlive(HttpMessage) instead.