com.noelios.restlet.http
Class HttpServerCall

java.lang.Object
  extended by com.noelios.restlet.http.HttpCall
      extended by com.noelios.restlet.http.HttpServerCall
Direct Known Subclasses:
StreamServerCall

public abstract class HttpServerCall
extends HttpCall

Abstract HTTP server connector call.

Author:
Jerome Louvel

Constructor Summary
HttpServerCall(Server server)
          Constructor.
HttpServerCall(java.lang.String serverAddress, int serverPort)
          Constructor.
 
Method Summary
 void complete()
          Complete the response
static java.lang.String formatContentDisposition(java.lang.String fileName)
          Format fileName as a Content-Disposition header value
protected  long getContentLength()
          Returns the content length of the request entity if know, Representation.UNKNOWN_SIZE otherwise.
 java.lang.String getHostDomain()
          Returns the host domain name.
 int getHostPort()
          Returns the host port.
 Representation getRequestEntity()
          Returns the request entity if available.
abstract  java.nio.channels.ReadableByteChannel getRequestEntityChannel(long size)
          Returns the request entity channel if it exists.
abstract  java.io.InputStream getRequestEntityStream(long size)
          Returns the request entity stream if it exists.
abstract  java.nio.channels.ReadableByteChannel getRequestHeadChannel()
          Returns the request head channel if it exists.
abstract  java.io.InputStream getRequestHeadStream()
          Returns the request head stream if it exists.
abstract  java.nio.channels.WritableByteChannel getResponseEntityChannel()
          Returns the response channel if it exists.
abstract  java.io.OutputStream getResponseEntityStream()
          Returns the response entity stream if it exists.
 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.
 java.lang.Integer getSslKeySize()
          Returns the SSL key size, if available and accessible.
protected  boolean isClientKeepAlive()
          Indicates if the client wants a persistent connection.
protected  boolean isServerKeepAlive()
          Indicates if the server wants a persistent connection.
protected  void readRequestHead(java.io.InputStream headStream)
          Reads the HTTP request head (request line and headers).
 void sendResponse(Response response)
          Sends the response back to the client.
protected  boolean shouldResponseBeChunked(Response response)
          Indicates if the response should be chunked because its length is unknown.
 void writeResponseBody(Representation entity, java.nio.channels.WritableByteChannel responseEntityChannel, java.io.OutputStream responseEntityStream)
          Effectively writes the response body.
 void writeResponseHead(Response response)
          Writes the response status line and headers.
protected  void writeResponseHead(Response response, java.io.OutputStream headStream)
          Writes the response head to the given output stream.
 
Methods inherited from class com.noelios.restlet.http.HttpCall
formatDate, getClientAddress, getClientPort, getConnectorService, getContentLength, getLogger, getMethod, getProtocol, getReasonPhrase, getRequestHeaders, getRequestUri, getResponseHeaders, getServerAddress, getServerPort, getStatusCode, getVersion, isConfidential, isConnectionBroken, isKeepAlive, isRequestChunked, isResponseChunked, parseDate, setClientAddress, setClientPort, setConfidential, setHostDomain, setHostPort, setMethod, setProtocol, setReasonPhrase, setRequestUri, setServerAddress, setServerPort, setStatusCode, setVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpServerCall

public HttpServerCall(java.lang.String serverAddress,
                      int serverPort)
Constructor.

Parameters:
serverAddress - The server IP address.
serverPort - The server port.

HttpServerCall

public HttpServerCall(Server server)
Constructor.

Parameters:
server - The parent server connector.
Method Detail

formatContentDisposition

public static java.lang.String formatContentDisposition(java.lang.String fileName)
Format fileName as a Content-Disposition header value

Parameters:
fileName - Filename to format
Returns:
fileName formatted

complete

public void complete()
Complete the response


getContentLength

protected long getContentLength()
Returns the content length of the request entity if know, Representation.UNKNOWN_SIZE otherwise.

Returns:
The request content length.

getHostDomain

public java.lang.String getHostDomain()
Returns the host domain name.

Overrides:
getHostDomain in class HttpCall
Returns:
The host domain name.

getHostPort

public int getHostPort()
Returns the host port.

Overrides:
getHostPort in class HttpCall
Returns:
The host port.

getRequestEntity

public Representation getRequestEntity()
Returns the request entity if available.

Returns:
The request entity if available.

getRequestEntityChannel

public abstract java.nio.channels.ReadableByteChannel getRequestEntityChannel(long size)
Returns the request entity channel if it exists.

Parameters:
size - The expected entity size or -1 if unknown.
Returns:
The request entity channel if it exists.

getRequestEntityStream

public abstract java.io.InputStream getRequestEntityStream(long size)
Returns the request entity stream if it exists.

Parameters:
size - The expected entity size or -1 if unknown.
Returns:
The request entity stream if it exists.

getRequestHeadChannel

public abstract java.nio.channels.ReadableByteChannel getRequestHeadChannel()
Returns the request head channel if it exists.

Returns:
The request head channel if it exists.

getRequestHeadStream

public abstract java.io.InputStream getRequestHeadStream()
Returns the request head stream if it exists.

Returns:
The request head stream if it exists.

getResponseEntityChannel

public abstract java.nio.channels.WritableByteChannel getResponseEntityChannel()
Returns the response channel if it exists.

Returns:
The response channel if it exists.

getResponseEntityStream

public abstract java.io.OutputStream getResponseEntityStream()
Returns the response entity stream if it exists.

Returns:
The response entity stream if it exists.

getSslCipherSuite

public java.lang.String getSslCipherSuite()
Returns the SSL Cipher Suite, if available and accessible.

Returns:
The SSL Cipher Suite, if available and accessible.

getSslClientCertificates

public java.util.List<java.security.cert.Certificate> getSslClientCertificates()
Returns the chain of client certificates, if available and accessible.

Returns:
The chain of client certificates, if available and accessible.

getSslKeySize

public java.lang.Integer getSslKeySize()
Returns the SSL key size, if available and accessible.

Returns:
The SSL key size, if available and accessible.

isClientKeepAlive

protected boolean isClientKeepAlive()
Description copied from class: HttpCall
Indicates if the client wants a persistent connection.

Specified by:
isClientKeepAlive in class HttpCall
Returns:
True if the client wants a persistent connection.

isServerKeepAlive

protected boolean isServerKeepAlive()
Description copied from class: HttpCall
Indicates if the server wants a persistent connection.

Specified by:
isServerKeepAlive in class HttpCall
Returns:
True if the server wants a persistent connection.

readRequestHead

protected void readRequestHead(java.io.InputStream headStream)
                        throws java.io.IOException
Reads the HTTP request head (request line and headers).

Throws:
java.io.IOException

sendResponse

public void sendResponse(Response response)
                  throws java.io.IOException
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 reponse stream or channel. Subclasses will probably also copy the response headers and status.

Parameters:
response - The high-level response.
Throws:
java.io.IOException - if the Response could not be written to the network.

shouldResponseBeChunked

protected boolean shouldResponseBeChunked(Response response)
Indicates if the response should be chunked because its length is unknown.

Parameters:
response - The response to analyze.
Returns:
True if the response should be chunked.

writeResponseBody

public void writeResponseBody(Representation entity,
                              java.nio.channels.WritableByteChannel responseEntityChannel,
                              java.io.OutputStream responseEntityStream)
                       throws java.io.IOException
Effectively writes the response body. The entity to write is guaranteed to be non null. Attempts to write the entity on the response channel or response stream by default.

Parameters:
entity - The representation to write as entity of the body.
responseEntityChannel - The response entity channel or null if a stream is used.
responseEntityStream - The response entity stream or null if a channel is used.
Throws:
java.io.IOException

writeResponseHead

public void writeResponseHead(Response response)
                       throws java.io.IOException
Writes the response status line and headers. Does nothing by default.

Parameters:
response - The response.
Throws:
java.io.IOException

writeResponseHead

protected void writeResponseHead(Response response,
                                 java.io.OutputStream headStream)
                          throws java.io.IOException
Writes the response head to the given output stream.

Parameters:
response - The response.
headStream - The output stream to write to.
Throws:
java.io.IOException


Copyright © 2005-2008 Noelios Technologies.