Save This Page
Home » HttpComponents-Core-4.0.1 » org.apache.http » [javadoc | source]
    1   /*
    2    * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/httpcore/src/main/java/org/apache/http/HttpResponse.java $
    3    * $Revision: 744522 $
    4    * $Date: 2009-02-14 17:56:03 +0100 (Sat, 14 Feb 2009) $
    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   
   32   package org.apache.http;
   33   
   34   import java.util.Locale;
   35   
   36   /**
   37    * After receiving and interpreting a request message, a server responds
   38    * with an HTTP response message.
   39    * <pre>
   40    *     Response      = Status-Line
   41    *                     *(( general-header
   42    *                      | response-header
   43    *                      | entity-header ) CRLF)
   44    *                     CRLF
   45    *                     [ message-body ]
   46    * </pre>
   47    *
   48    *
   49    * @version $Revision: 744522 $
   50    * 
   51    * @since 4.0
   52    */
   53   public interface HttpResponse extends HttpMessage {
   54   
   55       /**
   56        * Obtains the status line of this response.
   57        * The status line can be set using one of the
   58        * {@link #setStatusLine setStatusLine} methods,
   59        * or it can be initialized in a constructor.
   60        *
   61        * @return  the status line, or <code>null</code> if not yet set
   62        */
   63       StatusLine getStatusLine();
   64   
   65       /**
   66        * Sets the status line of this response.
   67        *
   68        * @param statusline the status line of this response
   69        */
   70       void setStatusLine(StatusLine statusline);
   71   
   72       /**
   73        * Sets the status line of this response.
   74        * The reason phrase will be determined based on the current
   75        * {@link #getLocale locale}.
   76        *
   77        * @param ver       the HTTP version
   78        * @param code      the status code
   79        */
   80       void setStatusLine(ProtocolVersion ver, int code);
   81   
   82       /**
   83        * Sets the status line of this response with a reason phrase.
   84        *
   85        * @param ver       the HTTP version
   86        * @param code      the status code
   87        * @param reason    the reason phrase, or <code>null</code> to omit
   88        */
   89       void setStatusLine(ProtocolVersion ver, int code, String reason);
   90       
   91       /**
   92        * Updates the status line of this response with a new status code.
   93        * The status line can only be updated if it is available. It must
   94        * have been set either explicitly or in a constructor.
   95        * <br/>
   96        * The reason phrase will be updated according to the new status code,
   97        * based on the current {@link #getLocale locale}. It can be set
   98        * explicitly using {@link #setReasonPhrase setReasonPhrase}.
   99        * 
  100        * @param code the HTTP status code.
  101        *
  102        * @throws IllegalStateException
  103        *          if the status line has not be set
  104        *
  105        * @see HttpStatus
  106        * @see #setStatusLine(StatusLine)
  107        * @see #setStatusLine(ProtocolVersion,int)
  108        */
  109       void setStatusCode(int code)
  110           throws IllegalStateException;
  111   
  112       /**
  113        * Updates the status line of this response with a new reason phrase.
  114        * The status line can only be updated if it is available. It must
  115        * have been set either explicitly or in a constructor.
  116        *
  117        * @param reason    the new reason phrase as a single-line string, or
  118        *                  <code>null</code> to unset the reason phrase
  119        *
  120        * @throws IllegalStateException
  121        *          if the status line has not be set
  122        *
  123        * @see #setStatusLine(StatusLine)
  124        * @see #setStatusLine(ProtocolVersion,int)
  125        */
  126       void setReasonPhrase(String reason)
  127           throws IllegalStateException;
  128   
  129       /**
  130        * Obtains the message entity of this response, if any.
  131        * The entity is provided by calling {@link #setEntity setEntity}.
  132        *
  133        * @return  the response entity, or
  134        *          <code>null</code> if there is none
  135        */
  136       HttpEntity getEntity();
  137       
  138       /**
  139        * Associates a response entity with this response.
  140        *
  141        * @param entity    the entity to associate with this response, or
  142        *                  <code>null</code> to unset
  143        */
  144       void setEntity(HttpEntity entity);
  145   
  146       /**
  147        * Obtains the locale of this response.
  148        * The locale is used to determine the reason phrase
  149        * for the {@link #setStatusCode status code}.
  150        * It can be changed using {@link #setLocale setLocale}.
  151        *
  152        * @return  the locale of this response, never <code>null</code>
  153        */
  154       Locale getLocale();
  155   
  156       /**
  157        * Changes the locale of this response.
  158        * If there is a status line, it's reason phrase will be updated
  159        * according to the status code and new locale.
  160        *
  161        * @param loc       the new locale
  162        *
  163        * @see #getLocale getLocale
  164        * @see #setStatusCode setStatusCode
  165        */
  166       void setLocale(Locale loc);
  167   }

Save This Page
Home » HttpComponents-Core-4.0.1 » org.apache.http » [javadoc | source]