org.jboss.netty.handler.codec.http

## Class DefaultHttpMessage

- java.lang.Object
- - org.jboss.netty.handler.codec.http.DefaultHttpMessage

- All Implemented Interfaces:
    HttpMessage
  Direct Known Subclasses:
    DefaultHttpRequest, DefaultHttpResponse

      public class DefaultHttpMessage
      extends Object
      implements HttpMessage

  The default `HttpMessage` implementation.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `DefaultHttpMessage(HttpVersion version)` Creates a new instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `long` | `getContentLength(long defaultValue)` Deprecated.
    `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 `HttpChunk`s, which is generated by `HttpMessageDecoder` consecutively, contain the actual content.
    `boolean` | `isKeepAlive()` Deprecated.
    `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 `HttpChunk`s, 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.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultHttpMessage

          protected DefaultHttpMessage(HttpVersion version)

      Creates a new instance.

  - ### Method Detail

    - #### addHeader

          public void addHeader(String name,
                       Object value)

      Description copied from interface: `HttpMessage`
      Adds a new header with the specified name and value.
      Specified by:
        `addHeader` in interface `HttpMessage`

    - #### setHeader

          public void setHeader(String name,
                       Object value)

      Description copied from interface: `HttpMessage`
      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.
      Specified by:
        `setHeader` in interface `HttpMessage`

    - #### setHeader

          public void setHeader(String name,
                       Iterable<?> values)

      Description copied from interface: `HttpMessage`
      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.
      Specified by:
        `setHeader` in interface `HttpMessage`

    - #### removeHeader

          public void removeHeader(String name)

      Description copied from interface: `HttpMessage`
      Removes the header with the specified name.
      Specified by:
        `removeHeader` in interface `HttpMessage`

    - #### getContentLength

          @Deprecated
          public long getContentLength()

      Deprecated.
      Specified by:
        `getContentLength` in interface `HttpMessage`

    - #### getContentLength

          @Deprecated
          public long getContentLength(long defaultValue)

      Deprecated.
      Specified by:
        `getContentLength` in interface `HttpMessage`

    - #### isChunked

          public boolean isChunked()

      Description copied from interface: `HttpMessage`
      Returns `true` if and only if this message does not have any content but the `HttpChunk`s, 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 `HttpMessage.setChunked(boolean)` with `false`.

      Specified by:
        `isChunked` in interface `HttpMessage`

    - #### setChunked

          public void setChunked(boolean chunked)

      Description copied from interface: `HttpMessage`
      Sets if this message does not have any content but the `HttpChunk`s, 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`, `HttpMessage.isChunked()` will keep returning `true` if the `"Transfer-Encoding"` of this message is `"chunked"`.

      Specified by:
        `setChunked` in interface `HttpMessage`

    - #### isKeepAlive

          @Deprecated
          public boolean isKeepAlive()

      Deprecated.
      Specified by:
        `isKeepAlive` in interface `HttpMessage`

    - #### clearHeaders

          public void clearHeaders()

      Description copied from interface: `HttpMessage`
      Removes all headers from this message.
      Specified by:
        `clearHeaders` in interface `HttpMessage`

    - #### setContent

          public void setContent(ChannelBuffer content)

      Description copied from interface: `HttpMessage`
      Sets the content of this message. If `null` is specified, the content of this message will be set to `ChannelBuffers.EMPTY_BUFFER`.
      Specified by:
        `setContent` in interface `HttpMessage`

    - #### getHeader

          public String getHeader(String name)

      Description copied from interface: `HttpMessage`
      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.
      Specified by:
        `getHeader` in interface `HttpMessage`
      Returns:
        the header value or `null` if there is no such header

    - #### getHeaders

          public List<String> getHeaders(String name)

      Description copied from interface: `HttpMessage`
      Returns the header values with the specified header name.
      Specified by:
        `getHeaders` in interface `HttpMessage`
      Returns:
        the `List` of header values. An empty list if there is no such header.

    - #### getHeaders

          public List<Map.Entry<String,String>> getHeaders()

      Description copied from interface: `HttpMessage`
      Returns the all header names and values that this message contains.
      Specified by:
        `getHeaders` in interface `HttpMessage`
      Returns:
        the `List` of the header name-value pairs. An empty list if there is no header in this message.

    - #### containsHeader

          public boolean containsHeader(String name)

      Description copied from interface: `HttpMessage`
      Returns `true` if and only if there is a header with the specified header name.
      Specified by:
        `containsHeader` in interface `HttpMessage`

    - #### getHeaderNames

          public Set<String> getHeaderNames()

      Description copied from interface: `HttpMessage`
      Returns the `Set` of all header names that this message contains.
      Specified by:
        `getHeaderNames` in interface `HttpMessage`

    - #### getProtocolVersion

          public HttpVersion getProtocolVersion()

      Description copied from interface: `HttpMessage`
      Returns the protocol version of this message.
      Specified by:
        `getProtocolVersion` in interface `HttpMessage`

    - #### setProtocolVersion

          public void setProtocolVersion(HttpVersion version)

      Description copied from interface: `HttpMessage`
      Sets the protocol version of this message.
      Specified by:
        `setProtocolVersion` in interface `HttpMessage`

    - #### getContent

          public ChannelBuffer getContent()

      Description copied from interface: `HttpMessage`
      Returns the content of this message. If there is no content or `HttpMessage.isChunked()` returns `true`, an `ChannelBuffers.EMPTY_BUFFER` is returned.
      Specified by:
        `getContent` in interface `HttpMessage`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2008-2012 The Netty Project. All Rights Reserved.