View Javadoc
1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.handler.codec.http;
17  
18  import java.util.List;
19  import java.util.Map;
20  import java.util.Set;
21  
22  import org.jboss.netty.buffer.ChannelBuffer;
23  import org.jboss.netty.buffer.ChannelBuffers;
24  
25  /**
26   * An HTTP message which provides common properties for {@link HttpRequest} and
27   * {@link HttpResponse}.
28   * @see HttpHeaders
29   *
30   * @apiviz.landmark
31   * @apiviz.has org.jboss.netty.handler.codec.http.HttpChunk oneway - - is followed by
32   */
33  public interface HttpMessage {
34  
35      /**
36       * Returns the protocol version of this message.
37       */
38      HttpVersion getProtocolVersion();
39  
40      /**
41       * Sets the protocol version of this message.
42       */
43      void setProtocolVersion(HttpVersion version);
44  
45      /**
46       * Returns the headers of this message.
47       */
48      HttpHeaders headers();
49  
50      /**
51       * Returns the content of this message.  If there is no content or
52       * {@link #isChunked()} returns {@code true}, an
53       * {@link ChannelBuffers#EMPTY_BUFFER} is returned.
54       */
55      ChannelBuffer getContent();
56  
57      /**
58       * Sets the content of this message.  If {@code null} is specified,
59       * the content of this message will be set to {@link ChannelBuffers#EMPTY_BUFFER}.
60       */
61      void setContent(ChannelBuffer content);
62  
63      /**
64       * Returns {@code true} if and only if this message does not have any
65       * content but the {@link HttpChunk}s, which is generated by
66       * {@link HttpMessageDecoder} consecutively, contain the actual content.
67       * <p>
68       * Please note that this method will keep returning {@code true} if the
69       * {@code "Transfer-Encoding"} of this message is {@code "chunked"}, even if
70       * you attempt to override this property by calling {@link #setChunked(boolean)}
71       * with {@code false}.
72       */
73      boolean isChunked();
74  
75      /**
76       * Sets if this message does not have any content but the
77       * {@link HttpChunk}s, which is generated by {@link HttpMessageDecoder}
78       * consecutively, contain the actual content.
79       * <p>
80       * If this method is called with {@code true}, the content of this message
81       * becomes {@link ChannelBuffers#EMPTY_BUFFER}.
82       * <p>
83       * Even if this method is called with {@code false}, {@link #isChunked()}
84       * will keep returning {@code true} if the {@code "Transfer-Encoding"} of
85       * this message is {@code "chunked"}.
86       */
87      void setChunked(boolean chunked);
88  }