Home | History | Annotate | Download | only in client
      1 /*
      2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/RequestDirector.java $
      3  * $Revision: 676020 $
      4  * $Date: 2008-07-11 09:38:49 -0700 (Fri, 11 Jul 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 
     32 package org.apache.http.client;
     33 
     34 import java.io.IOException;
     35 
     36 import org.apache.http.HttpHost;
     37 import org.apache.http.HttpRequest;
     38 import org.apache.http.HttpResponse;
     39 import org.apache.http.HttpException;
     40 import org.apache.http.protocol.HttpContext;
     41 
     42 /**
     43  * A client-side request director.
     44  * The director decides which steps are necessary to execute a request.
     45  * It establishes connections and optionally processes redirects and
     46  * authentication challenges. The director may therefore generate and
     47  * send a sequence of requests in order to execute one initial request.
     48  *
     49  * <br/><b>Note:</b>
     50  * It is most likely that implementations of this interface will
     51  * allocate connections, and return responses that depend on those
     52  * connections for reading the response entity. Such connections
     53  * MUST be released, but that is out of the scope of a request director.
     54  *
     55  * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
     56  *
     57  *
     58  * <!-- empty lines to avoid svn diff problems -->
     59  * @version $Revision: 676020 $
     60  *
     61  * @since 4.0
     62  */
     63 public interface RequestDirector {
     64 
     65 
     66     /**
     67      * Executes a request.
     68      * <br/><b>Note:</b>
     69      * For the time being, a new director is instantiated for each request.
     70      * This is the same behavior as for <code>HttpMethodDirector</code>
     71      * in HttpClient 3.
     72      *
     73      * @param target    the target host for the request.
     74      *                  Implementations may accept <code>null</code>
     75      *                  if they can still determine a route, for example
     76      *                  to a default target or by inspecting the request.
     77      * @param request   the request to execute
     78      * @param context   the context for executing the request
     79      *
     80      * @return  the final response to the request.
     81      *          This is never an intermediate response with status code 1xx.
     82      *
     83      * @throws HttpException            in case of a problem
     84      * @throws IOException              in case of an IO problem
     85      *                                     or if the connection was aborted
     86      */
     87     HttpResponse execute(HttpHost target, HttpRequest request,
     88                          HttpContext context)
     89         throws HttpException, IOException
     90         ;
     91 
     92 } // class ClientRequestDirector
     93