1/*2 * ====================================================================3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing,14 * software distributed under the License is distributed on an15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY16 * KIND, either express or implied. See the License for the17 * specific language governing permissions and limitations18 * under the License.19 * ====================================================================20 *21 * This software consists of voluntary contributions made by many22 * individuals on behalf of the Apache Software Foundation. For more23 * information on the Apache Software Foundation, please see24 * <http://www.apache.org/>.25 *26 */2728package org.apache.http;
2930import org.apache.http.params.HttpParams;
3132/**33 * HTTP messages consist of requests from client to server and responses34 * from server to client.35 * <pre>36 * HTTP-message = Request | Response ; HTTP/1.1 messages37 * </pre>38 * <p>39 * HTTP messages use the generic message format of RFC 822 for40 * transferring entities (the payload of the message). Both types41 * of message consist of a start-line, zero or more header fields42 * (also known as "headers"), an empty line (i.e., a line with nothing43 * preceding the CRLF) indicating the end of the header fields,44 * and possibly a message-body.45 * </p>46 * <pre>47 * generic-message = start-line48 * *(message-header CRLF)49 * CRLF50 * [ message-body ]51 * start-line = Request-Line | Status-Line52 * </pre>53 *54 * @since 4.055 */56 @SuppressWarnings("deprecation")
57publicinterfaceHttpMessage {
5859/**60 * Returns the protocol version this message is compatible with.61 */62ProtocolVersion getProtocolVersion();
6364/**65 * Checks if a certain header is present in this message. Header values are66 * ignored.67 *68 * @param name the header name to check for.69 * @return true if at least one header with this name is present.70 */71boolean containsHeader(String name);
7273/**74 * Returns all the headers with a specified name of this message. Header values75 * are ignored. Headers are orderd in the sequence they will be sent over a76 * connection.77 *78 * @param name the name of the headers to return.79 * @return the headers whose name property equals {@code name}.80 */81Header[] getHeaders(String name);
8283/**84 * Returns the first header with a specified name of this message. Header85 * values are ignored. If there is more than one matching header in the86 * message the first element of {@link #getHeaders(String)} is returned.87 * If there is no matching header in the message {@code null} is88 * returned.89 *90 * @param name the name of the header to return.91 * @return the first header whose name property equals {@code name}92 * or {@code null} if no such header could be found.93 */94Header getFirstHeader(String name);
9596/**97 * Returns the last header with a specified name of this message. Header values98 * are ignored. If there is more than one matching header in the message the99 * last element of {@link #getHeaders(String)} is returned. If there is no100 * matching header in the message {@code null} is returned.101 *102 * @param name the name of the header to return.103 * @return the last header whose name property equals {@code name}.104 * or {@code null} if no such header could be found.105 */106Header getLastHeader(String name);
107108/**109 * Returns all the headers of this message. Headers are orderd in the sequence110 * they will be sent over a connection.111 *112 * @return all the headers of this message113 */114Header[] getAllHeaders();
115116/**117 * Adds a header to this message. The header will be appended to the end of118 * the list.119 *120 * @param header the header to append.121 */122void addHeader(Header header);
123124/**125 * Adds a header to this message. The header will be appended to the end of126 * the list.127 *128 * @param name the name of the header.129 * @param value the value of the header.130 */131void addHeader(String name, String value);
132133/**134 * Overwrites the first header with the same name. The new header will be appended to135 * the end of the list, if no header with the given name can be found.136 *137 * @param header the header to set.138 */139void setHeader(Header header);
140141/**142 * Overwrites the first header with the same name. The new header will be appended to143 * the end of the list, if no header with the given name can be found.144 *145 * @param name the name of the header.146 * @param value the value of the header.147 */148void setHeader(String name, String value);
149150/**151 * Overwrites all the headers in the message.152 *153 * @param headers the array of headers to set.154 */155void setHeaders(Header[] headers);
156157/**158 * Removes a header from this message.159 *160 * @param header the header to remove.161 */162void removeHeader(Header header);
163164/**165 * Removes all headers with a certain name from this message.166 *167 * @param name The name of the headers to remove.168 */169void removeHeaders(String name);
170171/**172 * Returns an iterator of all the headers.173 *174 * @return Iterator that returns Header objects in the sequence they are175 * sent over a connection.176 */177HeaderIterator headerIterator();
178179/**180 * Returns an iterator of the headers with a given name.181 *182 * @param name the name of the headers over which to iterate, or183 * {@code null} for all headers184 *185 * @return Iterator that returns Header objects with the argument name186 * in the sequence they are sent over a connection.187 */188HeaderIterator headerIterator(String name);
189190/**191 * Returns the parameters effective for this message as set by192 * {@link #setParams(HttpParams)}.193 *194 * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'195 * and 'org.apache.http.client.config'196 */197 @Deprecated
198HttpParams getParams();
199200/**201 * Provides parameters to be used for the processing of this message.202 * @param params the parameters203 *204 * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'205 * and 'org.apache.http.client.config'206 */207 @Deprecated
208void setParams(HttpParams params);
209210 }