org.eclipse.actf.util.httpproxy.core

## Interface IClientConnection

All Known Subinterfaces:
  IHTTPProxyConnection

    public interface IClientConnection

A connection with client.

### Method Summary

Methods
`void` `allowTunnel(IHTTPRequestMessage req, org.eclipse.actf.util.internal.httpproxy.core.ServerConnection sc, long timeout)` Allow to establish tunnel for connect request
`String` `close()` Close the connection.
`Socket` `getClientSocket()` Get a socket object for connecting with the client.
`int` `getCurrentServerGroupIndex()` Gets index of the current server group.
`boolean` `isHandlingRequest()` Returns whether this connection is handling a request but a response is not sent yet.
`void` `rejectTunnel(IHTTPRequestMessage req, long timeout)` Reject to establish tunnel for connect request
`void` `resetConnection()` Reset the connection.
`void` `run()` Continuously read requests from the client and put them into the send queue of the dispatcher.
`void` `sendResponse(IHTTPResponseMessage response)` Send a HTTP response message to the client.
`void` `sendResponse(long timeout, IHTTPResponseMessage response)` Send a HTTP response message to the client.
`void` `sendResponse(long timeout, IHTTPResponseMessage response, boolean readyToHandleRequest)` Send a HTTP response message to the client.

### Method Detail

#### resetConnection

    void resetConnection()

Reset the connection.

#### close

    String close()

Close the connection.

Returns:
  name of this connection which can be used for debug messages

#### getClientSocket

    Socket getClientSocket()

Get a socket object for connecting with the client.

Returns:
  a Socket object

#### getCurrentServerGroupIndex

    int getCurrentServerGroupIndex()

Gets index of the current server group.

Returns:
  index of the current server group

#### isHandlingRequest

    boolean isHandlingRequest()

Returns whether this connection is handling a request but a response is not sent yet.

Returns:
  true if this connection is handling a request

#### sendResponse

    void sendResponse(long timeout,
                    IHTTPResponseMessage response,
                    boolean readyToHandleRequest)
                      throws InterruptedException,
                             IOException,
                             TimeoutException

Send a HTTP response message to the client.

Parameters:
  `timeout` - Number of milliseconds to wait until the response is sent to the client, or 0 if it does not need to timeout
  `response` - a HTTP response message
  `readyToHandleRequest` - true if "handlingRequest" status needs to be set to false after the response is sent successfully
Throws:
  `InterruptedException`
  `IOException`
  `TimeoutException` - if it failed to send the response within the specified time
See Also:
  `isHandlingRequest()`

#### sendResponse

    void sendResponse(long timeout,
                    IHTTPResponseMessage response)
                      throws InterruptedException,
                             IOException,
                             TimeoutException

Send a HTTP response message to the client. The "isHandlingRequest" status will be set to false after the response is sent successfully.

Parameters:
  `timeout` - Number of milliseconds to wait until the response is sent to the client, or 0 if it does not need to timeout
  `response` - a HTTP response message
Throws:
  `InterruptedException`
  `IOException`
  `TimeoutException` - if it failed to send the response within the specified time
See Also:
  `isHandlingRequest()`

#### sendResponse

    void sendResponse(IHTTPResponseMessage response)
                      throws InterruptedException,
                             IOException

Send a HTTP response message to the client. This method will be blocked until it sends the response (no timeout). The "isHandleRequest" status will be set to false after the response is sent successfully.

Parameters:
  `response` - a HTTP response message
Throws:
  `InterruptedException`
  `IOException`
See Also:
  `isHandlingRequest()`

#### allowTunnel

    void allowTunnel(IHTTPRequestMessage req,
                   org.eclipse.actf.util.internal.httpproxy.core.ServerConnection sc,
                   long timeout)
                     throws InterruptedException,
                            TimeoutException,
                            IOException

Allow to establish tunnel for connect request

Parameters:
  `req` -
  `sc` -
  `timeout` -
Throws:
  `InterruptedException`
  `TimeoutException`
  `IOException`

#### rejectTunnel

    void rejectTunnel(IHTTPRequestMessage req,
                    long timeout)
                      throws InterruptedException,
                             TimeoutException,
                             IOException

Reject to establish tunnel for connect request

Parameters:
  `req` -
  `timeout` -
Throws:
  `InterruptedException`
  `TimeoutException`
  `IOException`

#### run

    void run()

Continuously read requests from the client and put them into the send queue of the dispatcher.