Source code: org/apache/http/HttpMessage.java
1 /*
2 * $HeadURL: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/tags/4.0-alpha2/src/java/org/apache/http/HttpMessage.java $
3 * $Revision: 391251 $
4 * $Date: 2006-04-04 10:52:13 +0200 (Tue, 04 Apr 2006) $
5 *
6 * ====================================================================
7 *
8 * Copyright 1999-2006 The Apache Software Foundation
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ====================================================================
22 *
23 * This software consists of voluntary contributions made by many
24 * individuals on behalf of the Apache Software Foundation. For more
25 * information on the Apache Software Foundation, please see
26 * <http://www.apache.org/>.
27 *
28 */
29
30 package org.apache.http;
31
32 import java.util.Iterator;
33
34 import org.apache.http.params.HttpParams;
35
36 /**
37 * A generic HTTP message.
38 * Holds what is common between requests and responses.
39 *
40 * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
41 *
42 * @version $Revision: 391251 $
43 *
44 * @since 4.0
45 */
46 public interface HttpMessage {
47
48 /**
49 * Returns the HTTP version this message is compatible with.
50 */
51 HttpVersion getHttpVersion();
52
53 /**
54 * Checks if a certain header is present in this message. Header values are
55 * ignored.
56 *
57 * @param name the header name to check for.
58 * @return true if at least one header with this name is present.
59 */
60 boolean containsHeader(String name);
61
62 /**
63 * Returns all the headers with a specified name of this message. Header values
64 * are ignored. Headers are orderd in the sequence they will be sent over a
65 * connection.
66 *
67 * @param name the name of the headers to return.
68 * @return the headers whose name property equals <code>name</code>.
69 */
70 Header[] getHeaders(String name);
71
72 /**
73 * Returns the first header with a specified name of this message. Header
74 * values are ignored. If there is more than one matching header in the
75 * message the first element of
76 *
77 * @link #getHeaders(String) is returned.
78 * @param name the name of the header to return.
79 * @return the first header whose name property equals <code>name</code>.
80 */
81 Header getFirstHeader(String name);
82
83 /**
84 * Returns the last header with a specified name of this message. Header values
85 * are ignored. If there is more than one matching header in the message the
86 * last element of
87 *
88 * @link #getHeaders(String) is returned.
89 * @param name the name of the header to return.
90 * @return the last header whose name property equals <code>name</code>.
91 */
92 Header getLastHeader(String name);
93
94 /**
95 * Returns all the headers of this message. Headers are orderd in the sequence
96 * they will be sent over a connection.
97 *
98 * @return all the headers of this message
99 */
100 Header[] getAllHeaders();
101
102 /**
103 * Adds a header to this message. The header will be appended to the end of
104 * the list.
105 *
106 * @param header the header to append.
107 */
108 void addHeader(Header header);
109
110 /**
111 * Adds a header to this message. The new header will be appended to the end
112 * of the list. Existing headers with the same name will be removed.
113 *
114 * @param header the header to add.
115 */
116 void setHeader(Header header);
117
118 /**
119 * Removes a header from this message.
120 *
121 * @param header the header to remove.
122 */
123 void removeHeader(Header header);
124
125 /**
126 * Removes all headers with a certain name from this message.
127 *
128 * @param name The name of the headers to remove.
129 */
130 void removeHeaders(String name);
131
132 /**
133 * Returns an iterator of all the headers.
134 *
135 * @return Iterator that returns Header objects in the sequence they are
136 * sent over a connection.
137 */
138 Iterator headerIterator();
139
140 /**
141 * Returns the parameters effective for this message as set by
142 * @link #setParams(HttpParams).
143 */
144 HttpParams getParams();
145
146 /**
147 * Provides parameters to be used for the processing of this message.
148 * @param params the parameters
149 */
150 void setParams(HttpParams params);
151
152 }