org.apache.http
Interface HttpClientConnection

All Superinterfaces:
HttpConnection
All Known Subinterfaces:
HttpProxyConnection
All Known Implementing Classes:
DefaultHttpClientConnection, DefaultHttpProxyConnection

public interface HttpClientConnection
extends HttpConnection

An HTTP connection for use on the client side. It is used for sending requests and receiving responses. TODO add local port

Since:
4.0
Version:
$Revision: 391251 $
Author:
Oleg Kalnichevski

Method Summary
 void flush()
          Writes out all pending buffered data over the open connection.
 java.net.InetAddress getLocalAddress()
          The local address the connection is or will be bound to as set by
 HttpHost getTargetHost()
          Returns the current target host as set by @link #setTargetHost(HttpHost).
 boolean isResponseAvailable(int timeout)
          Checks if response data is available from the connection.
 void open(HttpParams params)
          Opens the connection.
 void receiveResponseEntity(HttpResponse response)
          Receives the next response entity available from this connection and attaches it to an existing HttpResponse object.
 HttpResponse receiveResponseHeader(HttpParams params)
          Receives the request line and headers of the next response available from this connection.
 void sendRequestEntity(HttpEntityEnclosingRequest request)
          Sends the request entity over the connection.
 void sendRequestHeader(HttpRequest request)
          Sends the request line and all headers over the connection.
 void setLocalAddress(java.net.InetAddress localAddress)
          Sets the local address the connection will be bound to upon opening.
 void setTargetHost(HttpHost targethost)
          Provides the implementation with the host it is supposed to connect to.
 
Methods inherited from interface org.apache.http.HttpConnection
close, isOpen, isStale, shutdown
 

Method Detail

getTargetHost

HttpHost getTargetHost()
Returns the current target host as set by @link #setTargetHost(HttpHost).

Returns:
the target host of this connection

setTargetHost

void setTargetHost(HttpHost targethost)
Provides the implementation with the host it is supposed to connect to. The host must be set prior to a call to

Parameters:
targethost - the host to connect to

getLocalAddress

java.net.InetAddress getLocalAddress()
The local address the connection is or will be bound to as set by

Returns:
local address the connection

setLocalAddress

void setLocalAddress(java.net.InetAddress localAddress)
Sets the local address the connection will be bound to upon opening. The local address can not only be set as long as the connection is not open. If no local address is specified it is up to the implementation to decide.

Parameters:
localAddress - the local bind address or null.

open

void open(HttpParams params)
          throws java.io.IOException
Opens the connection. Implementations may use additional settings from the HttpParams hierarchy.

Parameters:
params - the parameters in effect for this connection.
Throws:
java.io.IOException

isResponseAvailable

boolean isResponseAvailable(int timeout)
                            throws java.io.IOException
Checks if response data is available from the connection. May wait for the specified time until some data becomes available. Note that some implementations may completely ignore the timeout parameter.

Parameters:
timeout - the maximum time in milliseconds to wait for data
Returns:
true if data is available; false if there was no data available even after waiting for timeout milliseconds.
Throws:
java.io.IOException - if an error happens on the connection

sendRequestHeader

void sendRequestHeader(HttpRequest request)
                       throws HttpException,
                              java.io.IOException
Sends the request line and all headers over the connection.

Parameters:
request - the request whose headers to send.
Throws:
HttpException
java.io.IOException

sendRequestEntity

void sendRequestEntity(HttpEntityEnclosingRequest request)
                       throws HttpException,
                              java.io.IOException
Sends the request entity over the connection.

Parameters:
request - the request whose entity to send.
Throws:
HttpException
java.io.IOException

receiveResponseHeader

HttpResponse receiveResponseHeader(HttpParams params)
                                   throws HttpException,
                                          java.io.IOException
Receives the request line and headers of the next response available from this connection. The caller should examine the HttpResponse object to find out if it should try to receive a response entity as well.

Parameters:
params - the parameters in effect
Returns:
a new HttpResponse object with status line and headers initialized.
Throws:
HttpException
java.io.IOException

receiveResponseEntity

void receiveResponseEntity(HttpResponse response)
                           throws HttpException,
                                  java.io.IOException
Receives the next response entity available from this connection and attaches it to an existing HttpResponse object.

Parameters:
response - the response to attach the entity to
Throws:
HttpException
java.io.IOException

flush

void flush()
           throws java.io.IOException
Writes out all pending buffered data over the open connection.

Throws:
java.io.IOException


Copyright 2005-2005-2006 Apache Software Foundation. All Rights Reserved.