1/* 2 * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpMessage.java $ 3 * $Revision: 610823 $ 4 * $Date: 2008-01-10 07:53:53 -0800 (Thu, 10 Jan 2008) $ 5 * 6 * ==================================================================== 7 * Licensed to the Apache Software Foundation (ASF) under one 8 * or more contributor license agreements. See the NOTICE file 9 * distributed with this work for additional information 10 * regarding copyright ownership. The ASF licenses this file 11 * to you under the Apache License, Version 2.0 (the 12 * "License"); you may not use this file except in compliance 13 * with the License. You may obtain a copy of the License at 14 * 15 * http://www.apache.org/licenses/LICENSE-2.0 16 * 17 * Unless required by applicable law or agreed to in writing, 18 * software distributed under the License is distributed on an 19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 * KIND, either express or implied. See the License for the 21 * specific language governing permissions and limitations 22 * under the License. 23 * ==================================================================== 24 * 25 * This software consists of voluntary contributions made by many 26 * individuals on behalf of the Apache Software Foundation. For more 27 * information on the Apache Software Foundation, please see 28 * <http://www.apache.org/>. 29 * 30 */ 31 32package org.apache.http; 33 34import 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: 610823 $ 43 * 44 * @since 4.0 45 * 46 * @deprecated Please use {@link java.net.URL#openConnection} instead. 47 * Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a> 48 * for further details. 49 */ 50@Deprecated 51public interface HttpMessage { 52 53 /** 54 * Returns the protocol version this message is compatible with. 55 */ 56 ProtocolVersion getProtocolVersion(); 57 58 /** 59 * Checks if a certain header is present in this message. Header values are 60 * ignored. 61 * 62 * @param name the header name to check for. 63 * @return true if at least one header with this name is present. 64 */ 65 boolean containsHeader(String name); 66 67 /** 68 * Returns all the headers with a specified name of this message. Header values 69 * are ignored. Headers are orderd in the sequence they will be sent over a 70 * connection. 71 * 72 * @param name the name of the headers to return. 73 * @return the headers whose name property equals <code>name</code>. 74 */ 75 Header[] getHeaders(String name); 76 77 /** 78 * Returns the first header with a specified name of this message. Header 79 * values are ignored. If there is more than one matching header in the 80 * message the first element of {@link #getHeaders(String)} is returned. 81 * If there is no matching header in the message <code>null</code> is 82 * returned. 83 * 84 * @param name the name of the header to return. 85 * @return the first header whose name property equals <code>name</code> 86 * or <code>null</code> if no such header could be found. 87 */ 88 Header getFirstHeader(String name); 89 90 /** 91 * Returns the last header with a specified name of this message. Header values 92 * are ignored. If there is more than one matching header in the message the 93 * last element of {@link #getHeaders(String)} is returned. If there is no 94 * matching header in the message <code>null</code> is returned. 95 * 96 * @param name the name of the header to return. 97 * @return the last header whose name property equals <code>name</code>. 98 * or <code>null</code> if no such header could be found. 99 */ 100 Header getLastHeader(String name); 101 102 /** 103 * Returns all the headers of this message. Headers are orderd in the sequence 104 * they will be sent over a connection. 105 * 106 * @return all the headers of this message 107 */ 108 Header[] getAllHeaders(); 109 110 /** 111 * Adds a header to this message. The header will be appended to the end of 112 * the list. 113 * 114 * @param header the header to append. 115 */ 116 void addHeader(Header header); 117 118 /** 119 * Adds a header to this message. The header will be appended to the end of 120 * the list. 121 * 122 * @param name the name of the header. 123 * @param value the value of the header. 124 */ 125 void addHeader(String name, String value); 126 127 /** 128 * Overwrites the first header with the same name. The new header will be appended to 129 * the end of the list, if no header with the given name can be found. 130 * 131 * @param header the header to set. 132 */ 133 void setHeader(Header header); 134 135 /** 136 * Overwrites the first header with the same name. The new header will be appended to 137 * the end of the list, if no header with the given name can be found. 138 * 139 * @param name the name of the header. 140 * @param value the value of the header. 141 */ 142 void setHeader(String name, String value); 143 144 /** 145 * Overwrites all the headers in the message. 146 * 147 * @param headers the array of headers to set. 148 */ 149 void setHeaders(Header[] headers); 150 151 /** 152 * Removes a header from this message. 153 * 154 * @param header the header to remove. 155 */ 156 void removeHeader(Header header); 157 158 /** 159 * Removes all headers with a certain name from this message. 160 * 161 * @param name The name of the headers to remove. 162 */ 163 void removeHeaders(String name); 164 165 /** 166 * Returns an iterator of all the headers. 167 * 168 * @return Iterator that returns Header objects in the sequence they are 169 * sent over a connection. 170 */ 171 HeaderIterator headerIterator(); 172 173 /** 174 * Returns an iterator of the headers with a given name. 175 * 176 * @param name the name of the headers over which to iterate, or 177 * <code>null</code> for all headers 178 * 179 * @return Iterator that returns Header objects with the argument name 180 * in the sequence they are sent over a connection. 181 */ 182 HeaderIterator headerIterator(String name); 183 184 /** 185 * Returns the parameters effective for this message as set by 186 * {@link #setParams(HttpParams)}. 187 */ 188 HttpParams getParams(); 189 190 /** 191 * Provides parameters to be used for the processing of this message. 192 * @param params the parameters 193 */ 194 void setParams(HttpParams params); 195 196} 197