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 (contact@noelios.com)

Constructor Summary
HttpServerCall(Logger logger, String serverAddress, int serverPort)
          Constructor.
HttpServerCall(Server server)
          Constructor.
 
Method Summary
 String getHostDomain()
          Returns the host domain name.
 int getHostPort()
          Returns the host port.
abstract  ReadableByteChannel getRequestChannel()
          Returns the request entity channel if it exists.
 Representation getRequestEntity()
          Returns the request entity if available.
abstract  InputStream getRequestStream()
          Returns the request entity stream if it exists.
abstract  WritableByteChannel getResponseChannel()
          Returns the response channel if it exists.
abstract  OutputStream getResponseStream()
          Returns the response stream if it exists.
protected  void readRequestHead(InputStream headStream)
          Reads the HTTP request head (request line and headers).
 void sendResponse(Response response)
          Sends the response back to the client.
 void writeResponseBody(Representation entity)
          Effectively writes the response body.
protected  void writeResponseHead(OutputStream headStream)
          Writes the response head to the given output stream.
 void writeResponseHead(Response response)
          Writes the response status line and headers.
 
Methods inherited from class com.noelios.restlet.http.HttpCall
formatDate, getClientAddress, getClientPort, getConnectorService, getLogger, getMethod, getProtocol, getReasonPhrase, getRequestHeaders, getRequestUri, getResponseHeaders, getServerAddress, getServerPort, getStatusCode, getVersion, isConfidential, parseDate, setClientAddress, setClientPort, setConfidential, setHostDomain, setHostPort, setLogger, 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(Server server)
Constructor.

Parameters:
server - The parent server connector.

HttpServerCall

public HttpServerCall(Logger logger,
                      String serverAddress,
                      int serverPort)
Constructor.

Parameters:
logger - The logger.
serverAddress - The server IP address.
serverPort - The server port.
Method Detail

getRequestChannel

public abstract ReadableByteChannel getRequestChannel()
Returns the request entity channel if it exists.

Returns:
The request entity channel if it exists.

getRequestStream

public abstract InputStream getRequestStream()
Returns the request entity stream if it exists.

Returns:
The request entity stream if it exists.

getResponseChannel

public abstract WritableByteChannel getResponseChannel()
Returns the response channel if it exists.

Returns:
The response channel if it exists.

getResponseStream

public abstract OutputStream getResponseStream()
Returns the response stream if it exists.

Returns:
The response stream if it exists.

getRequestEntity

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

Returns:
The request entity if available.

getHostDomain

public 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.

readRequestHead

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

Throws:
IOException

sendResponse

public void sendResponse(Response response)
                  throws 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:
IOException

writeResponseBody

public void writeResponseBody(Representation entity)
                       throws 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.
Throws:
IOException

writeResponseHead

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

Parameters:
response - The response.
Throws:
IOException

writeResponseHead

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

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


Copyright © 2005-2007 Noelios Consulting.