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/HttpClient.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.params.HttpParams;
     40 import org.apache.http.protocol.HttpContext;
     41 import org.apache.http.client.methods.HttpUriRequest;
     42 import org.apache.http.conn.ClientConnectionManager;
     43 
     44 /**
     45  * Interface for an HTTP client.
     46  * HTTP clients encapsulate a smorgasbord of objects required to
     47  * execute HTTP requests while handling cookies, authentication,
     48  * connection management, and other features.
     49  * Thread safety of HTTP clients depends on the implementation
     50  * and configuration of the specific client.
     51  *
     52  * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
     53  *
     54  *
     55  * <!-- empty lines to avoid svn diff problems -->
     56  * @version   $Revision: 676020 $
     57  *
     58  * @since 4.0
     59  *
     60  * @deprecated Please use {@link java.net.URL#openConnection} instead.
     61  *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
     62  *     for further details.
     63  */
     64 @Deprecated
     65 public interface HttpClient {
     66 
     67 
     68     /**
     69      * Obtains the parameters for this client.
     70      * These parameters will become defaults for all requests being
     71      * executed with this client, and for the parameters of
     72      * dependent objects in this client.
     73      *
     74      * @return  the default parameters
     75      */
     76     HttpParams getParams()
     77         ;
     78 
     79 
     80     /**
     81      * Obtains the connection manager used by this client.
     82      *
     83      * @return  the connection manager
     84      */
     85     ClientConnectionManager getConnectionManager()
     86         ;
     87 
     88     /**
     89      * Executes a request using the default context.
     90      *
     91      * @param request   the request to execute
     92      *
     93      * @return  the response to the request. This is always a final response,
     94      *          never an intermediate response with an 1xx status code.
     95      *          Whether redirects or authentication challenges will be returned
     96      *          or handled automatically depends on the implementation and
     97      *          configuration of this client.
     98      * @throws IOException in case of a problem or the connection was aborted
     99      * @throws ClientProtocolException in case of an http protocol error
    100      */
    101     HttpResponse execute(HttpUriRequest request)
    102         throws IOException, ClientProtocolException
    103         ;
    104 
    105 
    106     /**
    107      * Executes a request using the given context.
    108      * The route to the target will be determined by the HTTP client.
    109      *
    110      * @param request   the request to execute
    111      * @param context   the context to use for the execution, or
    112      *                  <code>null</code> to use the default context
    113      *
    114      * @return  the response to the request. This is always a final response,
    115      *          never an intermediate response with an 1xx status code.
    116      *          Whether redirects or authentication challenges will be returned
    117      *          or handled automatically depends on the implementation and
    118      *          configuration of this client.
    119      * @throws IOException in case of a problem or the connection was aborted
    120      * @throws ClientProtocolException in case of an http protocol error
    121      */
    122     HttpResponse execute(HttpUriRequest request, HttpContext context)
    123         throws IOException, ClientProtocolException
    124         ;
    125 
    126 
    127     /**
    128      * Executes a request to the target using the default context.
    129      *
    130      * @param target    the target host for the request.
    131      *                  Implementations may accept <code>null</code>
    132      *                  if they can still determine a route, for example
    133      *                  to a default target or by inspecting the request.
    134      * @param request   the request to execute
    135      *
    136      * @return  the response to the request. This is always a final response,
    137      *          never an intermediate response with an 1xx status code.
    138      *          Whether redirects or authentication challenges will be returned
    139      *          or handled automatically depends on the implementation and
    140      *          configuration of this client.
    141      * @throws IOException in case of a problem or the connection was aborted
    142      * @throws ClientProtocolException in case of an http protocol error
    143      */
    144     HttpResponse execute(HttpHost target, HttpRequest request)
    145         throws IOException, ClientProtocolException
    146         ;
    147 
    148     /**
    149      * Executes a request to the target using the given context.
    150      *
    151      * @param target    the target host for the request.
    152      *                  Implementations may accept <code>null</code>
    153      *                  if they can still determine a route, for example
    154      *                  to a default target or by inspecting the request.
    155      * @param request   the request to execute
    156      * @param context   the context to use for the execution, or
    157      *                  <code>null</code> to use the default context
    158      *
    159      * @return  the response to the request. This is always a final response,
    160      *          never an intermediate response with an 1xx status code.
    161      *          Whether redirects or authentication challenges will be returned
    162      *          or handled automatically depends on the implementation and
    163      *          configuration of this client.
    164      * @throws IOException in case of a problem or the connection was aborted
    165      * @throws ClientProtocolException in case of an http protocol error
    166      */
    167     HttpResponse execute(HttpHost target, HttpRequest request,
    168                          HttpContext context)
    169         throws IOException, ClientProtocolException
    170         ;
    171 
    172     /**
    173      * Executes a request using the default context and processes the
    174      * response using the given response handler.
    175      *
    176      * @param request   the request to execute
    177      * @param responseHandler the response handler
    178      *
    179      * @return  the response object as generated by the response handler.
    180      * @throws IOException in case of a problem or the connection was aborted
    181      * @throws ClientProtocolException in case of an http protocol error
    182      */
    183     <T> T execute(
    184             HttpUriRequest request,
    185             ResponseHandler<? extends T> responseHandler)
    186         throws IOException, ClientProtocolException
    187         ;
    188 
    189     /**
    190      * Executes a request using the given context and processes the
    191      * response using the given response handler.
    192      *
    193      * @param request   the request to execute
    194      * @param responseHandler the response handler
    195      *
    196      * @return  the response object as generated by the response handler.
    197      * @throws IOException in case of a problem or the connection was aborted
    198      * @throws ClientProtocolException in case of an http protocol error
    199      */
    200     <T> T execute(
    201             HttpUriRequest request,
    202             ResponseHandler<? extends T> responseHandler,
    203             HttpContext context)
    204         throws IOException, ClientProtocolException
    205         ;
    206 
    207     /**
    208      * Executes a request to the target using the default context and
    209      * processes the response using the given response handler.
    210      *
    211      * @param target    the target host for the request.
    212      *                  Implementations may accept <code>null</code>
    213      *                  if they can still determine a route, for example
    214      *                  to a default target or by inspecting the request.
    215      * @param request   the request to execute
    216      * @param responseHandler the response handler
    217      *
    218      * @return  the response object as generated by the response handler.
    219      * @throws IOException in case of a problem or the connection was aborted
    220      * @throws ClientProtocolException in case of an http protocol error
    221      */
    222     <T> T execute(
    223             HttpHost target,
    224             HttpRequest request,
    225             ResponseHandler<? extends T> responseHandler)
    226         throws IOException, ClientProtocolException
    227         ;
    228 
    229     /**
    230      * Executes a request to the target using the given context and
    231      * processes the response using the given response handler.
    232      *
    233      * @param target    the target host for the request.
    234      *                  Implementations may accept <code>null</code>
    235      *                  if they can still determine a route, for example
    236      *                  to a default target or by inspecting the request.
    237      * @param request   the request to execute
    238      * @param responseHandler the response handler
    239      * @param context   the context to use for the execution, or
    240      *                  <code>null</code> to use the default context
    241      *
    242      * @return  the response object as generated by the response handler.
    243      * @throws IOException in case of a problem or the connection was aborted
    244      * @throws ClientProtocolException in case of an http protocol error
    245      */
    246     <T> T execute(
    247             HttpHost target,
    248             HttpRequest request,
    249             ResponseHandler<? extends T> responseHandler,
    250             HttpContext context)
    251         throws IOException, ClientProtocolException
    252         ;
    253 
    254 } // interface HttpClient
    255