001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/main/java/org/apache/http/HttpMessage.java $
003: * $Revision: 610823 $
004: * $Date: 2008-01-10 16:53:53 +0100 (Thu, 10 Jan 2008) $
005: *
006: * ====================================================================
007: * Licensed to the Apache Software Foundation (ASF) under one
008: * or more contributor license agreements. See the NOTICE file
009: * distributed with this work for additional information
010: * regarding copyright ownership. The ASF licenses this file
011: * to you under the Apache License, Version 2.0 (the
012: * "License"); you may not use this file except in compliance
013: * with the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing,
018: * software distributed under the License is distributed on an
019: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020: * KIND, either express or implied. See the License for the
021: * specific language governing permissions and limitations
022: * under the License.
023: * ====================================================================
024: *
025: * This software consists of voluntary contributions made by many
026: * individuals on behalf of the Apache Software Foundation. For more
027: * information on the Apache Software Foundation, please see
028: * <http://www.apache.org/>.
029: *
030: */
031:
032: package org.apache.http;
033:
034: import org.apache.http.params.HttpParams;
035:
036: /**
037: * A generic HTTP message.
038: * Holds what is common between requests and responses.
039: *
040: * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
041: *
042: * @version $Revision: 610823 $
043: *
044: * @since 4.0
045: */
046: public interface HttpMessage {
047:
048: /**
049: * Returns the protocol version this message is compatible with.
050: */
051: ProtocolVersion getProtocolVersion();
052:
053: /**
054: * Checks if a certain header is present in this message. Header values are
055: * ignored.
056: *
057: * @param name the header name to check for.
058: * @return true if at least one header with this name is present.
059: */
060: boolean containsHeader(String name);
061:
062: /**
063: * Returns all the headers with a specified name of this message. Header values
064: * are ignored. Headers are orderd in the sequence they will be sent over a
065: * connection.
066: *
067: * @param name the name of the headers to return.
068: * @return the headers whose name property equals <code>name</code>.
069: */
070: Header[] getHeaders(String name);
071:
072: /**
073: * Returns the first header with a specified name of this message. Header
074: * values are ignored. If there is more than one matching header in the
075: * message the first element of {@link #getHeaders(String)} is returned.
076: * If there is no matching header in the message <code>null</code> is
077: * returned.
078: *
079: * @param name the name of the header to return.
080: * @return the first header whose name property equals <code>name</code>
081: * or <code>null</code> if no such header could be found.
082: */
083: Header getFirstHeader(String name);
084:
085: /**
086: * Returns the last header with a specified name of this message. Header values
087: * are ignored. If there is more than one matching header in the message the
088: * last element of {@link #getHeaders(String)} is returned. If there is no
089: * matching header in the message <code>null</code> is returned.
090: *
091: * @param name the name of the header to return.
092: * @return the last header whose name property equals <code>name</code>.
093: * or <code>null</code> if no such header could be found.
094: */
095: Header getLastHeader(String name);
096:
097: /**
098: * Returns all the headers of this message. Headers are orderd in the sequence
099: * they will be sent over a connection.
100: *
101: * @return all the headers of this message
102: */
103: Header[] getAllHeaders();
104:
105: /**
106: * Adds a header to this message. The header will be appended to the end of
107: * the list.
108: *
109: * @param header the header to append.
110: */
111: void addHeader(Header header);
112:
113: /**
114: * Adds a header to this message. The header will be appended to the end of
115: * the list.
116: *
117: * @param name the name of the header.
118: * @param value the value of the header.
119: */
120: void addHeader(String name, String value);
121:
122: /**
123: * Overwrites the first header with the same name. The new header will be appended to
124: * the end of the list, if no header with the given name can be found.
125: *
126: * @param header the header to set.
127: */
128: void setHeader(Header header);
129:
130: /**
131: * Overwrites the first header with the same name. The new header will be appended to
132: * the end of the list, if no header with the given name can be found.
133: *
134: * @param name the name of the header.
135: * @param value the value of the header.
136: */
137: void setHeader(String name, String value);
138:
139: /**
140: * Overwrites all the headers in the message.
141: *
142: * @param headers the array of headers to set.
143: */
144: void setHeaders(Header[] headers);
145:
146: /**
147: * Removes a header from this message.
148: *
149: * @param header the header to remove.
150: */
151: void removeHeader(Header header);
152:
153: /**
154: * Removes all headers with a certain name from this message.
155: *
156: * @param name The name of the headers to remove.
157: */
158: void removeHeaders(String name);
159:
160: /**
161: * Returns an iterator of all the headers.
162: *
163: * @return Iterator that returns Header objects in the sequence they are
164: * sent over a connection.
165: */
166: HeaderIterator headerIterator();
167:
168: /**
169: * Returns an iterator of the headers with a given name.
170: *
171: * @param name the name of the headers over which to iterate, or
172: * <code>null</code> for all headers
173: *
174: * @return Iterator that returns Header objects with the argument name
175: * in the sequence they are sent over a connection.
176: */
177: HeaderIterator headerIterator(String name);
178:
179: /**
180: * Returns the parameters effective for this message as set by
181: * {@link #setParams(HttpParams)}.
182: */
183: HttpParams getParams();
184:
185: /**
186: * Provides parameters to be used for the processing of this message.
187: * @param params the parameters
188: */
189: void setParams(HttpParams params);
190:
191: }
|