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 * @deprecated Use {@link HttpMessage#headers()} instead.
37 */
38 @Deprecated
39 String getHeader(String name);
40
41 /**
42 * @deprecated Use {@link HttpMessage#headers()} instead.
43 */
44 @Deprecated
45 List<String> getHeaders(String name);
46
47 /**
48 * @deprecated Use {@link HttpMessage#headers()} instead.
49 */
50 @Deprecated
51 List<Map.Entry<String, String>> getHeaders();
52
53 /**
54 * @deprecated Use {@link HttpMessage#headers()} instead.
55 */
56 @Deprecated
57 boolean containsHeader(String name);
58
59 /**
60 * Returns the {@link Set} of all header names that this message contains.
61 */
62 @Deprecated
63 Set<String> getHeaderNames();
64
65 /**
66 * Returns the protocol version of this message.
67 */
68 HttpVersion getProtocolVersion();
69
70 /**
71 * Sets the protocol version of this message.
72 */
73 void setProtocolVersion(HttpVersion version);
74
75 /**
76 * Returns the headers of this message.
77 */
78 HttpHeaders headers();
79
80 /**
81 * Returns the content of this message. If there is no content or
82 * {@link #isChunked()} returns {@code true}, an
83 * {@link ChannelBuffers#EMPTY_BUFFER} is returned.
84 */
85 ChannelBuffer getContent();
86
87 /**
88 * Sets the content of this message. If {@code null} is specified,
89 * the content of this message will be set to {@link ChannelBuffers#EMPTY_BUFFER}.
90 */
91 void setContent(ChannelBuffer content);
92
93 /**
94 * @deprecated Use {@link HttpMessage#headers()} instead.
95 */
96 @Deprecated
97 void addHeader(String name, Object value);
98
99 /**
100 * @deprecated Use {@link HttpMessage#headers()} instead.
101 */
102 @Deprecated
103 void setHeader(String name, Object value);
104
105 /**
106 * @deprecated Use {@link HttpMessage#headers()} instead.
107 */
108 @Deprecated
109 void setHeader(String name, Iterable<?> values);
110
111 /**
112 * @deprecated Use {@link HttpMessage#headers()} instead.
113 */
114 @Deprecated
115 void removeHeader(String name);
116
117 /**
118 * @deprecated Use {@link HttpMessage#headers()} instead.
119 */
120 @Deprecated
121 void clearHeaders();
122
123 /**
124 * Returns {@code true} if and only if this message does not have any
125 * content but the {@link HttpChunk}s, which is generated by
126 * {@link HttpMessageDecoder} consecutively, contain the actual content.
127 * <p>
128 * Please note that this method will keep returning {@code true} if the
129 * {@code "Transfer-Encoding"} of this message is {@code "chunked"}, even if
130 * you attempt to override this property by calling {@link #setChunked(boolean)}
131 * with {@code false}.
132 */
133 boolean isChunked();
134
135 /**
136 * Sets if this message does not have any content but the
137 * {@link HttpChunk}s, which is generated by {@link HttpMessageDecoder}
138 * consecutively, contain the actual content.
139 * <p>
140 * If this method is called with {@code true}, the content of this message
141 * becomes {@link ChannelBuffers#EMPTY_BUFFER}.
142 * <p>
143 * Even if this method is called with {@code false}, {@link #isChunked()}
144 * will keep returning {@code true} if the {@code "Transfer-Encoding"} of
145 * this message is {@code "chunked"}.
146 */
147 void setChunked(boolean chunked);
148 }