001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/main/java/org/apache/http/HttpClientConnection.java $
003: * $Revision: 542199 $
004: * $Date: 2007-05-28 13:23:46 +0200 (Mon, 28 May 2007) $
005: *
006: * ====================================================================
007: * Licensed to the Apache Software Foundation (ASF) under one
008: * or more contributor license agreements. See the NOTICE file
009: * distributed with this work for additional information
010: * regarding copyright ownership. The ASF licenses this file
011: * to you under the Apache License, Version 2.0 (the
012: * "License"); you may not use this file except in compliance
013: * with the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing,
018: * software distributed under the License is distributed on an
019: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020: * KIND, either express or implied. See the License for the
021: * specific language governing permissions and limitations
022: * under the License.
023: * ====================================================================
024: *
025: * This software consists of voluntary contributions made by many
026: * individuals on behalf of the Apache Software Foundation. For more
027: * information on the Apache Software Foundation, please see
028: * <http://www.apache.org/>.
029: *
030: */
031:
032: package org.apache.http;
033:
034: import java.io.IOException;
035:
036: /**
037: * An HTTP connection for use on the client side.
038: * It is used for sending requests and receiving responses.
039: *
040: * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
041: *
042: *
043: * <!-- empty lines above to avoid 'svn diff' context problems -->
044: * @version $Revision: 542199 $
045: *
046: * @since 4.0
047: */
048: public interface HttpClientConnection extends HttpConnection {
049:
050: /**
051: * Checks if response data is available from the connection. May wait for
052: * the specified time until some data becomes available. Note that some
053: * implementations may completely ignore the timeout parameter.
054: *
055: * @param timeout the maximum time in milliseconds to wait for data
056: * @return true if data is available; false if there was no data available
057: * even after waiting for <code>timeout</code> milliseconds.
058: * @throws IOException if an error happens on the connection
059: */
060: boolean isResponseAvailable(int timeout) throws IOException;
061:
062: /**
063: * Sends the request line and all headers over the connection.
064: * @param request the request whose headers to send.
065: * @throws HttpException
066: * @throws IOException
067: */
068: void sendRequestHeader(HttpRequest request) throws HttpException,
069: IOException;
070:
071: /**
072: * Sends the request entity over the connection.
073: * @param request the request whose entity to send.
074: * @throws HttpException
075: * @throws IOException
076: */
077: void sendRequestEntity(HttpEntityEnclosingRequest request)
078: throws HttpException, IOException;
079:
080: /**
081: * Receives the request line and headers of the next response available from
082: * this connection. The caller should examine the HttpResponse object to
083: * find out if it should try to receive a response entity as well.
084: *
085: * @return a new HttpResponse object with status line and headers
086: * initialized.
087: * @throws HttpException
088: * @throws IOException
089: */
090: HttpResponse receiveResponseHeader() throws HttpException,
091: IOException;
092:
093: /**
094: * Receives the next response entity available from this connection and
095: * attaches it to an existing HttpResponse object.
096: *
097: * @param response the response to attach the entity to
098: * @throws HttpException
099: * @throws IOException
100: */
101: void receiveResponseEntity(HttpResponse response)
102: throws HttpException, IOException;
103:
104: /**
105: * Writes out all pending buffered data over the open connection.
106: *
107: * @throws IOException
108: */
109: void flush() throws IOException;
110:
111: }
|