blob: 84a994f41d8586ef0e4ab9d202b31c912a3ab58a [file] [log] [blame]
The Android Open Source Project069490a2009-03-03 19:29:16 -08001/*
2 * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpResponse.java $
3 * $Revision: 652956 $
4 * $Date: 2008-05-02 17:13:05 -0700 (Fri, 02 May 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
34
35import java.util.Locale;
36
37
38/**
39 * An HTTP response.
40 *
41 * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
42 *
43 * @version $Revision: 652956 $
44 *
45 * @since 4.0
Narayan Kamathd42abb22014-10-23 12:54:27 +010046 *
47 * @deprecated Please use {@link java.net.URL#openConnection} instead.
48 * Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
49 * for further details.
The Android Open Source Project069490a2009-03-03 19:29:16 -080050 */
Narayan Kamathd42abb22014-10-23 12:54:27 +010051@Deprecated
The Android Open Source Project069490a2009-03-03 19:29:16 -080052public interface HttpResponse extends HttpMessage {
53
54 /**
55 * Obtains the status line of this response.
56 * The status line can be set using one of the
57 * {@link #setStatusLine setStatusLine} methods,
58 * or it can be initialized in a constructor.
59 *
60 * @return the status line, or <code>null</code> if not yet set
61 */
62 StatusLine getStatusLine();
63
64 /**
65 * Sets the status line of this response.
66 *
67 * @param statusline the status line of this response
68 */
69 void setStatusLine(StatusLine statusline);
70
71 /**
72 * Sets the status line of this response.
73 * The reason phrase will be determined based on the current
74 * {@link #getLocale locale}.
75 *
76 * @param ver the HTTP version
77 * @param code the status code
78 */
79 void setStatusLine(ProtocolVersion ver, int code);
80
81 /**
82 * Sets the status line of this response with a reason phrase.
83 *
84 * @param ver the HTTP version
85 * @param code the status code
86 * @param reason the reason phrase, or <code>null</code> to omit
87 */
88 void setStatusLine(ProtocolVersion ver, int code, String reason);
89
90 /**
91 * Updates the status line of this response with a new status code.
92 * The status line can only be updated if it is available. It must
93 * have been set either explicitly or in a constructor.
94 * <br/>
95 * The reason phrase will be updated according to the new status code,
96 * based on the current {@link #getLocale locale}. It can be set
97 * explicitly using {@link #setReasonPhrase setReasonPhrase}.
98 *
99 * @param code the HTTP status code.
100 *
101 * @throws IllegalStateException
102 * if the status line has not be set
103 *
104 * @see HttpStatus
105 * @see #setStatusLine(StatusLine)
106 * @see #setStatusLine(ProtocolVersion,int)
107 */
108 void setStatusCode(int code)
109 throws IllegalStateException;
110
111 /**
112 * Updates the status line of this response with a new reason phrase.
113 * The status line can only be updated if it is available. It must
114 * have been set either explicitly or in a constructor.
115 *
116 * @param reason the new reason phrase as a single-line string, or
117 * <code>null</code> to unset the reason phrase
118 *
119 * @throws IllegalStateException
120 * if the status line has not be set
121 *
122 * @see #setStatusLine(StatusLine)
123 * @see #setStatusLine(ProtocolVersion,int)
124 */
125 void setReasonPhrase(String reason)
126 throws IllegalStateException;
127
128 /**
129 * Obtains the message entity of this response, if any.
130 * The entity is provided by calling {@link #setEntity setEntity}.
131 *
132 * @return the response entity, or
133 * <code>null</code> if there is none
134 */
135 HttpEntity getEntity();
136
137 /**
138 * Associates a response entity with this response.
139 *
140 * @param entity the entity to associate with this response, or
141 * <code>null</code> to unset
142 */
143 void setEntity(HttpEntity entity);
144
145 /**
146 * Obtains the locale of this response.
147 * The locale is used to determine the reason phrase
148 * for the {@link #setStatusCode status code}.
149 * It can be changed using {@link #setLocale setLocale}.
150 *
151 * @return the locale of this response, never <code>null</code>
152 */
153 Locale getLocale();
154
155 /**
156 * Changes the locale of this response.
157 * If there is a status line, it's reason phrase will be updated
158 * according to the status code and new locale.
159 *
160 * @param loc the new locale
161 *
162 * @see #getLocale getLocale
163 * @see #setStatusCode setStatusCode
164 */
165 void setLocale(Locale loc);
166}