Home | History | Annotate | Download | only in http
      1 /*
      2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpClientConnection.java $
      3  * $Revision: 542199 $
      4  * $Date: 2007-05-28 04:23:46 -0700 (Mon, 28 May 2007) $
      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.io.IOException;
     35 
     36 /**
     37  * An HTTP connection for use on the client side.
     38  * It is used for sending requests and receiving responses.
     39  *
     40  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
     41  *
     42  *
     43  * <!-- empty lines above to avoid 'svn diff' context problems -->
     44  * @version $Revision: 542199 $
     45  *
     46  * @since 4.0
     47  */
     48 public interface HttpClientConnection extends HttpConnection {
     49 
     50     /**
     51      * Checks if response data is available from the connection. May wait for
     52      * the specified time until some data becomes available. Note that some
     53      * implementations may completely ignore the timeout parameter.
     54      *
     55      * @param timeout the maximum time in milliseconds to wait for data
     56      * @return true if data is available; false if there was no data available
     57      *         even after waiting for <code>timeout</code> milliseconds.
     58      * @throws IOException if an error happens on the connection
     59      */
     60     boolean isResponseAvailable(int timeout)
     61         throws IOException;
     62 
     63     /**
     64      * Sends the request line and all headers over the connection.
     65      * @param request the request whose headers to send.
     66      * @throws HttpException
     67      * @throws IOException
     68      */
     69     void sendRequestHeader(HttpRequest request)
     70         throws HttpException, IOException;
     71 
     72     /**
     73      * Sends the request entity over the connection.
     74      * @param request the request whose entity to send.
     75      * @throws HttpException
     76      * @throws IOException
     77      */
     78     void sendRequestEntity(HttpEntityEnclosingRequest request)
     79         throws HttpException, IOException;
     80 
     81     /**
     82      * Receives the request line and headers of the next response available from
     83      * this connection. The caller should examine the HttpResponse object to
     84      * find out if it should try to receive a response entity as well.
     85      *
     86      * @return a new HttpResponse object with status line and headers
     87      *         initialized.
     88      * @throws HttpException
     89      * @throws IOException
     90      */
     91     HttpResponse receiveResponseHeader()
     92         throws HttpException, IOException;
     93 
     94     /**
     95      * Receives the next response entity available from this connection and
     96      * attaches it to an existing HttpResponse object.
     97      *
     98      * @param response the response to attach the entity to
     99      * @throws HttpException
    100      * @throws IOException
    101      */
    102     void receiveResponseEntity(HttpResponse response)
    103         throws HttpException, IOException;
    104 
    105     /**
    106      * Writes out all pending buffered data over the open connection.
    107      *
    108      * @throws IOException
    109      */
    110     void flush() throws IOException;
    111 
    112 }
    113