michael@0: /* michael@0: * ==================================================================== michael@0: * Licensed to the Apache Software Foundation (ASF) under one michael@0: * or more contributor license agreements. See the NOTICE file michael@0: * distributed with this work for additional information michael@0: * regarding copyright ownership. The ASF licenses this file michael@0: * to you under the Apache License, Version 2.0 (the michael@0: * "License"); you may not use this file except in compliance michael@0: * with the License. You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, michael@0: * software distributed under the License is distributed on an michael@0: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY michael@0: * KIND, either express or implied. See the License for the michael@0: * specific language governing permissions and limitations michael@0: * under the License. michael@0: * ==================================================================== michael@0: * michael@0: * This software consists of voluntary contributions made by many michael@0: * individuals on behalf of the Apache Software Foundation. For more michael@0: * information on the Apache Software Foundation, please see michael@0: * . michael@0: * michael@0: */ michael@0: michael@0: package ch.boye.httpclientandroidlib; michael@0: michael@0: import java.util.Locale; michael@0: michael@0: /** michael@0: * After receiving and interpreting a request message, a server responds michael@0: * with an HTTP response message. michael@0: *
michael@0:  *     Response      = Status-Line
michael@0:  *                     *(( general-header
michael@0:  *                      | response-header
michael@0:  *                      | entity-header ) CRLF)
michael@0:  *                     CRLF
michael@0:  *                     [ message-body ]
michael@0:  * 
michael@0: * michael@0: * @since 4.0 michael@0: */ michael@0: public interface HttpResponse extends HttpMessage { michael@0: michael@0: /** michael@0: * Obtains the status line of this response. michael@0: * The status line can be set using one of the michael@0: * {@link #setStatusLine setStatusLine} methods, michael@0: * or it can be initialized in a constructor. michael@0: * michael@0: * @return the status line, or null if not yet set michael@0: */ michael@0: StatusLine getStatusLine(); michael@0: michael@0: /** michael@0: * Sets the status line of this response. michael@0: * michael@0: * @param statusline the status line of this response michael@0: */ michael@0: void setStatusLine(StatusLine statusline); michael@0: michael@0: /** michael@0: * Sets the status line of this response. michael@0: * The reason phrase will be determined based on the current michael@0: * {@link #getLocale locale}. michael@0: * michael@0: * @param ver the HTTP version michael@0: * @param code the status code michael@0: */ michael@0: void setStatusLine(ProtocolVersion ver, int code); michael@0: michael@0: /** michael@0: * Sets the status line of this response with a reason phrase. michael@0: * michael@0: * @param ver the HTTP version michael@0: * @param code the status code michael@0: * @param reason the reason phrase, or null to omit michael@0: */ michael@0: void setStatusLine(ProtocolVersion ver, int code, String reason); michael@0: michael@0: /** michael@0: * Updates the status line of this response with a new status code. michael@0: * The status line can only be updated if it is available. It must michael@0: * have been set either explicitly or in a constructor. michael@0: *
michael@0: * The reason phrase will be updated according to the new status code, michael@0: * based on the current {@link #getLocale locale}. It can be set michael@0: * explicitly using {@link #setReasonPhrase setReasonPhrase}. michael@0: * michael@0: * @param code the HTTP status code. michael@0: * michael@0: * @throws IllegalStateException michael@0: * if the status line has not be set michael@0: * michael@0: * @see HttpStatus michael@0: * @see #setStatusLine(StatusLine) michael@0: * @see #setStatusLine(ProtocolVersion,int) michael@0: */ michael@0: void setStatusCode(int code) michael@0: throws IllegalStateException; michael@0: michael@0: /** michael@0: * Updates the status line of this response with a new reason phrase. michael@0: * The status line can only be updated if it is available. It must michael@0: * have been set either explicitly or in a constructor. michael@0: * michael@0: * @param reason the new reason phrase as a single-line string, or michael@0: * null to unset the reason phrase michael@0: * michael@0: * @throws IllegalStateException michael@0: * if the status line has not be set michael@0: * michael@0: * @see #setStatusLine(StatusLine) michael@0: * @see #setStatusLine(ProtocolVersion,int) michael@0: */ michael@0: void setReasonPhrase(String reason) michael@0: throws IllegalStateException; michael@0: michael@0: /** michael@0: * Obtains the message entity of this response, if any. michael@0: * The entity is provided by calling {@link #setEntity setEntity}. michael@0: * michael@0: * @return the response entity, or michael@0: * null if there is none michael@0: */ michael@0: HttpEntity getEntity(); michael@0: michael@0: /** michael@0: * Associates a response entity with this response. michael@0: * michael@0: * @param entity the entity to associate with this response, or michael@0: * null to unset michael@0: */ michael@0: void setEntity(HttpEntity entity); michael@0: michael@0: /** michael@0: * Obtains the locale of this response. michael@0: * The locale is used to determine the reason phrase michael@0: * for the {@link #setStatusCode status code}. michael@0: * It can be changed using {@link #setLocale setLocale}. michael@0: * michael@0: * @return the locale of this response, never null michael@0: */ michael@0: Locale getLocale(); michael@0: michael@0: /** michael@0: * Changes the locale of this response. michael@0: * If there is a status line, it's reason phrase will be updated michael@0: * according to the status code and new locale. michael@0: * michael@0: * @param loc the new locale michael@0: * michael@0: * @see #getLocale getLocale michael@0: * @see #setStatusCode setStatusCode michael@0: */ michael@0: void setLocale(Locale loc); michael@0: }