org.restlet.ext.netty.internal

## Class NettyServerCall

- java.lang.Object
- - org.restlet.engine.http.Call
  - - org.restlet.engine.http.ServerCall
    - - org.restlet.ext.netty.internal.NettyServerCall

    public class NettyServerCall
    extends ServerCall

Call that is used by the Netty HTTP server connectors.

Author:
  Gabriel Ciuloaica (gciuloaica@gmail.com), Jerome Louvel

### Constructor Summary

Constructors
Constructor and Description
`NettyServerCall(Server server, org.jboss.netty.channel.MessageEvent messageEvent, org.jboss.netty.buffer.ChannelBuffer contentBuffer, org.jboss.netty.handler.codec.http.HttpRequest request, java.net.InetSocketAddress clientAddress, boolean isConfidential, javax.net.ssl.SSLEngine sslEngine)` Constructor.

### Method Summary

Methods
`boolean` `abort()` Closes the socket.
`java.lang.String` `getClientAddress()` Returns the client address. Corresponds to the IP address of the requesting client.
`int` `getClientPort()` Returns the client port. Corresponds to the TCP/IP port of the requesting client.
`java.lang.String` `getMethod()` Returns the request method.
`java.nio.channels.ReadableByteChannel` `getRequestEntityChannel(long size)` Returns the request entity channel if it exists.
`java.io.InputStream` `getRequestEntityStream(long size)` Returns the request entity stream if it exists.
`java.nio.channels.ReadableByteChannel` `getRequestHeadChannel()` Returns the request head channel if it exists.
`Series<Parameter>` `getRequestHeaders()` Returns the modifiable list of request headers.
`java.io.InputStream` `getRequestHeadStream()` Returns the request head stream if it exists.
`java.lang.String` `getRequestUri()` Returns the URI on the request line (most like a relative reference, but not necessarily).
`org.jboss.netty.handler.codec.http.HttpResponse` `getResponse()` Get response.
`java.nio.channels.WritableByteChannel` `getResponseEntityChannel()` Returns the response channel if it exists.
`java.io.OutputStream` `getResponseEntityStream()` Returns the response entity stream if it exists.
`Response` `getRestletResponse()` Returns the Restlet response.
`java.lang.String` `getSslCipherSuite()` Returns the SSL Cipher Suite, if available and accessible.
`java.util.List<java.security.cert.Certificate>` `getSslClientCertificates()` Returns the chain of client certificates, if available and accessible.
`protected byte[]` `getSslSessionIdBytes()` Returns the SSL session ID, as a byte array, if available and accessible in that format (to be used by getSslSessionId).
`java.lang.String` `getVersion()` Returns the protocol version used.
`protected boolean` `isClientKeepAlive()` Indicates if the client wants a persistent connection.
`void` `sendResponse(Response response)` Sends the response back to the client.
`void` `setRestletResponse(Response restletResponse)` Sets the Restlet response.
`void` `writeResponseHead(Response restletResponse)` Writes the response status line and headers.

### Methods inherited from class org.restlet.engine.http.ServerCall

`complete, getContentLength, getHostDomain, getHostPort, getRequestEntity, getSslKeySize, getSslSessionId, isServerKeepAlive, readRequestHead, shouldResponseBeChunked, writeResponseBody, writeResponseHead`

### Methods inherited from class org.restlet.engine.http.Call

`getLogger, getProtocol, getReasonPhrase, getRepresentation, getRepresentation, getResponseHeaders, getServerAddress, getServerPort, getStatusCode, getUserPrincipal, isBroken, isConfidential, isConnectionBroken, isKeepAlive, isRequestChunked, isResponseChunked, setClientAddress, setClientPort, setConfidential, setHostDomain, setHostPort, setMethod, setProtocol, setReasonPhrase, setRequestUri, setServerAddress, setServerPort, setStatusCode, setUserPrincipal, setVersion`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### NettyServerCall

    public NettyServerCall(Server server,
                   org.jboss.netty.channel.MessageEvent messageEvent,
                   org.jboss.netty.buffer.ChannelBuffer contentBuffer,
                   org.jboss.netty.handler.codec.http.HttpRequest request,
                   java.net.InetSocketAddress clientAddress,
                   boolean isConfidential,
                   javax.net.ssl.SSLEngine sslEngine)

Constructor.

Parameters:
  `server` - The helped server.
  `messageEvent` - The message event received.
  `contentBuffer` - The content buffer.
  `request` - The Netty request.
  `clientAddress` - client information.
  `isConfidential` - Indicates if the call is confidential or not.
  `sslEngine` - The SSL engine.

### Method Detail

#### abort

    public boolean abort()

Closes the socket.

Specified by:
  `abort` in class `ServerCall`
Returns:
  True if the request was aborted.

#### getClientAddress

    public java.lang.String getClientAddress()

Description copied from class: `Call`
Returns the client address.
Corresponds to the IP address of the requesting client.

Overrides:
  `getClientAddress` in class `Call`
Returns:
  The client address.

#### getClientPort

    public int getClientPort()

Description copied from class: `Call`
Returns the client port.
Corresponds to the TCP/IP port of the requesting client.

Overrides:
  `getClientPort` in class `Call`
Returns:
  The client port.

#### getMethod

    public java.lang.String getMethod()

Description copied from class: `Call`
Returns the request method.

Overrides:
  `getMethod` in class `Call`
Returns:
  The request method.

#### getRequestEntityChannel

    public java.nio.channels.ReadableByteChannel getRequestEntityChannel(long size)

Description copied from class: `ServerCall`
Returns the request entity channel if it exists.

Specified by:
  `getRequestEntityChannel` in class `ServerCall`
Parameters:
  `size` - The expected entity size or -1 if unknown.
Returns:
  The request entity channel if it exists.

#### getRequestEntityStream

    public java.io.InputStream getRequestEntityStream(long size)

Description copied from class: `ServerCall`
Returns the request entity stream if it exists.

Specified by:
  `getRequestEntityStream` in class `ServerCall`
Parameters:
  `size` - The expected entity size or -1 if unknown.
Returns:
  The request entity stream if it exists.

#### getRequestHeadChannel

    public java.nio.channels.ReadableByteChannel getRequestHeadChannel()

Description copied from class: `ServerCall`
Returns the request head channel if it exists.

Specified by:
  `getRequestHeadChannel` in class `ServerCall`
Returns:
  The request head channel if it exists.

#### getRequestHeaders

    public Series<Parameter> getRequestHeaders()

Description copied from class: `Call`
Returns the modifiable list of request headers.

Overrides:
  `getRequestHeaders` in class `Call`
Returns:
  The modifiable list of request headers.

#### getRequestHeadStream

    public java.io.InputStream getRequestHeadStream()

Description copied from class: `ServerCall`
Returns the request head stream if it exists.

Specified by:
  `getRequestHeadStream` in class `ServerCall`
Returns:
  The request head stream if it exists.

#### getRequestUri

    public java.lang.String getRequestUri()

Description copied from class: `Call`
Returns the URI on the request line (most like a relative reference, but not necessarily).

Overrides:
  `getRequestUri` in class `Call`
Returns:
  The URI on the request line.

#### getResponse

    public org.jboss.netty.handler.codec.http.HttpResponse getResponse()

Get response.

Returns:
  the response

#### getResponseEntityChannel

    public java.nio.channels.WritableByteChannel getResponseEntityChannel()

Description copied from class: `ServerCall`
Returns the response channel if it exists.

Specified by:
  `getResponseEntityChannel` in class `ServerCall`
Returns:
  The response channel if it exists.

#### getResponseEntityStream

    public java.io.OutputStream getResponseEntityStream()

Description copied from class: `ServerCall`
Returns the response entity stream if it exists.

Specified by:
  `getResponseEntityStream` in class `ServerCall`
Returns:
  The response entity stream if it exists.

#### getRestletResponse

    public Response getRestletResponse()

Returns the Restlet response.

Returns:
  The Restlet response.

#### getSslCipherSuite

    public java.lang.String getSslCipherSuite()

Description copied from class: `ServerCall`
Returns the SSL Cipher Suite, if available and accessible.

Overrides:
  `getSslCipherSuite` in class `ServerCall`
Returns:
  The SSL Cipher Suite, if available and accessible.

#### getSslClientCertificates

    public java.util.List<java.security.cert.Certificate> getSslClientCertificates()

Description copied from class: `ServerCall`
Returns the chain of client certificates, if available and accessible.

Overrides:
  `getSslClientCertificates` in class `ServerCall`
Returns:
  The chain of client certificates, if available and accessible.

#### getSslSessionIdBytes

    protected byte[] getSslSessionIdBytes()

Description copied from class: `ServerCall`
Returns the SSL session ID, as a byte array, if available and accessible in that format (to be used by getSslSessionId).

Overrides:
  `getSslSessionIdBytes` in class `ServerCall`
Returns:
  The SSL session ID, as a byte array, if available and accessible in that format.

#### getVersion

    public java.lang.String getVersion()

Description copied from class: `Call`
Returns the protocol version used.

Overrides:
  `getVersion` in class `Call`
Returns:
  The protocol version used.

#### isClientKeepAlive

    protected boolean isClientKeepAlive()

Description copied from class: `Call`
Indicates if the client wants a persistent connection.

Overrides:
  `isClientKeepAlive` in class `ServerCall`
Returns:
  True if the client wants a persistent connection.

#### sendResponse

    public void sendResponse(Response response)
                      throws java.io.IOException

Description copied from class: `ServerCall`
Sends the response back to the client. Commits the status, headers and optional entity and send them over the network. The default implementation only writes the response entity on the response stream or channel. Subclasses will probably also copy the response headers and status.

Overrides:
  `sendResponse` in class `ServerCall`
Parameters:
  `response` - The high-level response.
Throws:
  `java.io.IOException` - if the Response could not be written to the network.

#### setRestletResponse

    public void setRestletResponse(Response restletResponse)

Sets the Restlet response.

Parameters:
  `restletResponse` - The Restlet response.

#### writeResponseHead

    public void writeResponseHead(Response restletResponse)
                           throws java.io.IOException

Description copied from class: `ServerCall`
Writes the response status line and headers. Does nothing by default.

Overrides:
  `writeResponseHead` in class `ServerCall`
Parameters:
  `restletResponse` - The response.
Throws:
  `java.io.IOException`