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 java.util.Locale;
3132/**33 * After receiving and interpreting a request message, a server responds34 * with an HTTP response message.35 * <pre>36 * Response = Status-Line37 * *(( general-header38 * | response-header39 * | entity-header ) CRLF)40 * CRLF41 * [ message-body ]42 * </pre>43 *44 * @since 4.045 */46publicinterfaceHttpResponseextendsHttpMessage {
4748/**49 * Obtains the status line of this response.50 * The status line can be set using one of the51 * {@link #setStatusLine setStatusLine} methods,52 * or it can be initialized in a constructor.53 *54 * @return the status line, or <code>null</code> if not yet set55 */56StatusLine getStatusLine();
5758/**59 * Sets the status line of this response.60 *61 * @param statusline the status line of this response62 */63void setStatusLine(StatusLine statusline);
6465/**66 * Sets the status line of this response.67 * The reason phrase will be determined based on the current68 * {@link #getLocale locale}.69 *70 * @param ver the HTTP version71 * @param code the status code72 */73void setStatusLine(ProtocolVersion ver, int code);
7475/**76 * Sets the status line of this response with a reason phrase.77 *78 * @param ver the HTTP version79 * @param code the status code80 * @param reason the reason phrase, or <code>null</code> to omit81 */82void setStatusLine(ProtocolVersion ver, int code, String reason);
8384/**85 * Updates the status line of this response with a new status code.86 * The status line can only be updated if it is available. It must87 * have been set either explicitly or in a constructor.88 * <br/>89 * The reason phrase will be updated according to the new status code,90 * based on the current {@link #getLocale locale}. It can be set91 * explicitly using {@link #setReasonPhrase setReasonPhrase}.92 *93 * @param code the HTTP status code.94 *95 * @throws IllegalStateException96 * if the status line has not be set97 *98 * @see HttpStatus99 * @see #setStatusLine(StatusLine)100 * @see #setStatusLine(ProtocolVersion,int)101 */102void setStatusCode(int code)
103throws IllegalStateException;
104105/**106 * Updates the status line of this response with a new reason phrase.107 * The status line can only be updated if it is available. It must108 * have been set either explicitly or in a constructor.109 *110 * @param reason the new reason phrase as a single-line string, or111 * <code>null</code> to unset the reason phrase112 *113 * @throws IllegalStateException114 * if the status line has not be set115 *116 * @see #setStatusLine(StatusLine)117 * @see #setStatusLine(ProtocolVersion,int)118 */119void setReasonPhrase(String reason)
120throws IllegalStateException;
121122/**123 * Obtains the message entity of this response, if any.124 * The entity is provided by calling {@link #setEntity setEntity}.125 *126 * @return the response entity, or127 * <code>null</code> if there is none128 */129HttpEntity getEntity();
130131/**132 * Associates a response entity with this response.133 * <p/>134 * Please note that if an entity has already been set for this response and it depends on 135 * an input stream ({@link HttpEntity#isStreaming()} returns <code>true</code>), 136 * it must be fully consumed in order to ensure release of resources.137 *138 * @param entity the entity to associate with this response, or139 * <code>null</code> to unset140 * 141 * @see HttpEntity#isStreaming()142 */143void setEntity(HttpEntity entity);
144145/**146 * Obtains the locale of this response.147 * The locale is used to determine the reason phrase148 * 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();
154155/**156 * Changes the locale of this response.157 * If there is a status line, it's reason phrase will be updated158 * according to the status code and new locale.159 *160 * @param loc the new locale161 *162 * @see #getLocale getLocale163 * @see #setStatusCode setStatusCode164 */165void setLocale(Locale loc);
166 }