org.restlet.engine.http.connector
Class ClientConnection

java.lang.Object
  extended by org.restlet.engine.http.connector.Connection<Client>
      extended by org.restlet.engine.http.connector.ClientConnection
All Implemented Interfaces:
Notifiable

public class ClientConnection
extends Connection<Client>

Generic HTTP-like client connection.

Author:
Jerome Louvel

Constructor Summary
ClientConnection(BaseHelper<Client> helper, Socket socket, SocketChannel socketChannel)
          Constructor.
 
Method Summary
protected  void addRequestHeaders(Request request, Series<Parameter> headers)
          Adds the request headers.
 boolean canEnqueue()
          Indicates whether the client connection can accept a new message.
 boolean canRead()
          Indicates if the connection's socket can be read for inbound data.
 boolean canWrite()
          Indicates if the connection's socket can be written for outbound data.
protected  void copyResponseTransportHeaders(Series<Parameter> headers, Response response)
          Copies headers into a response.
protected  Status createStatus(int code)
          Returns the status corresponding to a given status code.
protected  void readMessage()
          Reads the next message received via the inbound stream or channel.
protected  void writeMessage(Response response)
          Write the given response on the socket.
protected  void writeMessageHeadLine(Response message, OutputStream headStream)
          Writes the message head line to the given output stream.
 
Methods inherited from class org.restlet.engine.http.connector.Connection
addEntityHeaders, addGeneralHeaders, close, createInboundEntity, getAddress, getHelper, getInboundEntityChannel, getInboundEntityStream, getInboundMessages, getInboundStream, getLogger, getOutboundEntityChannel, getOutboundEntityStream, getOutboundMessages, getOutboundStream, getPort, getRepresentation, getRepresentation, getSocket, getSocketChannel, getSslCipherSuite, getSslClientCertificates, getSslKeySize, getState, isBusy, isClientSide, isInboundBusy, isOutboundBusy, isPersistent, isPipelining, isServerSide, onEndReached, onError, open, readMessages, setInboundBusy, setOutboundBusy, setPersistent, setPipelining, setState, shouldBeChunked, writeMessage, writeMessageBody, writeMessageHead, writeMessageHead, writeMessages
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientConnection

public ClientConnection(BaseHelper<Client> helper,
                        Socket socket,
                        SocketChannel socketChannel)
                 throws IOException
Constructor.

Parameters:
helper - The parent connector helper.
socket - The underlying BIO socket.
socketChannel - The underlying NIO socket channel.
Throws:
IOException
Method Detail

addRequestHeaders

protected void addRequestHeaders(Request request,
                                 Series<Parameter> headers)
Adds the request headers.

Parameters:
request - The request to inspect.
headers - The headers series to update.

canEnqueue

public boolean canEnqueue()
Indicates whether the client connection can accept a new message.

Returns:
True if the client connection can accept a new message.

canRead

public boolean canRead()
Description copied from class: Connection
Indicates if the connection's socket can be read for inbound data.

Overrides:
canRead in class Connection<Client>
Returns:
True if the connection's socket can be read for inbound data.

canWrite

public boolean canWrite()
Description copied from class: Connection
Indicates if the connection's socket can be written for outbound data.

Overrides:
canWrite in class Connection<Client>
Returns:
True if the connection's socket can be written for outbound data.

copyResponseTransportHeaders

protected void copyResponseTransportHeaders(Series<Parameter> headers,
                                            Response response)
Copies headers into a response.

Parameters:
headers - The headers to copy.
response - The response to update.

createStatus

protected Status createStatus(int code)
Returns the status corresponding to a given status code.

Parameters:
code - The status code.
Returns:
The status corresponding to a given status code.

readMessage

protected void readMessage()
                    throws IOException
Description copied from class: Connection
Reads the next message received via the inbound stream or channel. Note that the optional entity is not fully read.

Specified by:
readMessage in class Connection<Client>
Throws:
IOException

writeMessage

protected void writeMessage(Response response)
Write the given response on the socket.

Specified by:
writeMessage in class Connection<Client>
Parameters:
response - The response to write.

writeMessageHeadLine

protected void writeMessageHeadLine(Response message,
                                    OutputStream headStream)
                             throws IOException
Description copied from class: Connection
Writes the message head line to the given output stream.

Specified by:
writeMessageHeadLine in class Connection<Client>
Parameters:
message - The source message.
headStream - The target stream.
Throws:
IOException


Copyright © 2005-2011 Noelios Technologies.