com.noelios.restlet.http
Class HttpCall

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

public abstract class HttpCall
extends java.lang.Object

Low-level call for the HTTP connectors.

Author:
Jerome Louvel

Constructor Summary
HttpCall()
          Constructor.
 
Method Summary
static java.lang.String formatDate(java.util.Date date, boolean cookie)
          Formats a date as a header string.
 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.
 ConnectorService getConnectorService(Request request)
          Returns the connector service associated to a request.
protected  long getContentLength(Series<Parameter> headers)
          Returns the content length of the request entity if know, Representation.UNKNOWN_SIZE otherwise.
 java.lang.String getHostDomain()
          Returns the host domain.
 int getHostPort()
          Returns the host port.
 java.util.logging.Logger getLogger()
          Returns the logger.
 java.lang.String getMethod()
          Returns the request method.
 Protocol getProtocol()
          Returns the exact protocol (HTTP or HTTPS).
 java.lang.String getReasonPhrase()
          Returns the reason phrase.
 Series<Parameter> getRequestHeaders()
          Returns the modifiable list of request headers.
 java.lang.String getRequestUri()
          Returns the URI on the request line (most like a relative reference, but not necessarily).
 Series<Parameter> getResponseHeaders()
          Returns the modifiable list of server headers.
 java.lang.String getServerAddress()
          Returns the response address.
Corresponds to the IP address of the responding server.
 int getServerPort()
          Returns the server port.
 int getStatusCode()
          Returns the status code.
 java.lang.String getVersion()
          Returns the protocol version used.
protected abstract  boolean isClientKeepAlive()
          Indicates if the client wants a persistent connection.
 boolean isConfidential()
          Indicates if the confidentiality of the call is ensured (ex: via SSL).
 boolean isConnectionBroken(java.lang.Exception exception)
          Returns true if the given exception is caused by a broken connection.
protected  boolean isKeepAlive()
          Indicates if both the client and the server want a persistent connection.
protected  boolean isRequestChunked()
          Indicates if the request entity is chunked.
protected  boolean isResponseChunked()
          Indicates if the response entity is chunked.
protected abstract  boolean isServerKeepAlive()
          Indicates if the server wants a persistent connection.
static java.util.Date parseDate(java.lang.String date, boolean cookie)
          Parses a date string.
protected  void setClientAddress(java.lang.String clientAddress)
          Sets the client address.
protected  void setClientPort(int clientPort)
          Sets the client port.
protected  void setConfidential(boolean confidential)
          Indicates if the confidentiality of the call is ensured (ex: via SSL).
 void setHostDomain(java.lang.String hostDomain)
          Sets the host domain name.
 void setHostPort(int hostPort)
          Sets the host port.
protected  void setMethod(java.lang.String method)
          Sets the request method.
 void setProtocol(Protocol protocol)
          Sets the exact protocol used (HTTP or HTTPS).
 void setReasonPhrase(java.lang.String reasonPhrase)
          Sets the reason phrase.
protected  void setRequestUri(java.lang.String requestUri)
          Sets the full request URI.
 void setServerAddress(java.lang.String responseAddress)
          Sets the response address.
Corresponds to the IP address of the responding server.
 void setServerPort(int serverPort)
          Sets the server port.
 void setStatusCode(int code)
          Sets the status code.
 void setVersion(java.lang.String version)
          Sets the protocol version used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpCall

public HttpCall()
Constructor.

Method Detail

formatDate

public static java.lang.String formatDate(java.util.Date date,
                                          boolean cookie)
Formats a date as a header string.

Parameters:
date - The date to format.
cookie - Indicates if the date should be in the cookie format.
Returns:
The formatted date.

parseDate

public static java.util.Date parseDate(java.lang.String date,
                                       boolean cookie)
Parses a date string.

Parameters:
date - The date string to parse.
cookie - Indicates if the date is in the cookie format.
Returns:
The parsed date.

getClientAddress

public java.lang.String getClientAddress()
Returns the client address.
Corresponds to the IP address of the requesting client.

Returns:
The client address.

getClientPort

public int getClientPort()
Returns the client port.
Corresponds to the TCP/IP port of the requesting client.

Returns:
The client port.

getConnectorService

public ConnectorService getConnectorService(Request request)
Returns the connector service associated to a request.

Parameters:
request - The request to lookup.
Returns:
The connector service associated to a request.

getContentLength

protected long getContentLength(Series<Parameter> headers)
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.

Returns:
The host domain.

getHostPort

public int getHostPort()
Returns the host port.

Returns:
The host port.

getLogger

public java.util.logging.Logger getLogger()
Returns the logger.

Returns:
The logger.

getMethod

public java.lang.String getMethod()
Returns the request method.

Returns:
The request method.

getProtocol

public Protocol getProtocol()
Returns the exact protocol (HTTP or HTTPS).

Returns:
The exact protocol (HTTP or HTTPS).

getReasonPhrase

public java.lang.String getReasonPhrase()
Returns the reason phrase.

Returns:
The reason phrase.

getRequestHeaders

public Series<Parameter> getRequestHeaders()
Returns the modifiable list of request headers.

Returns:
The modifiable list of request headers.

getRequestUri

public java.lang.String getRequestUri()
Returns the URI on the request line (most like a relative reference, but not necessarily).

Returns:
The URI on the request line.

getResponseHeaders

public Series<Parameter> getResponseHeaders()
Returns the modifiable list of server headers.

Returns:
The modifiable list of server headers.

getServerAddress

public java.lang.String getServerAddress()
Returns the response address.
Corresponds to the IP address of the responding server.

Returns:
The response address.

getServerPort

public int getServerPort()
Returns the server port.

Returns:
The server port.

getStatusCode

public int getStatusCode()
                  throws java.io.IOException
Returns the status code.

Returns:
The status code.
Throws:
java.io.IOException

getVersion

public java.lang.String getVersion()
Returns the protocol version used.

Returns:
The protocol version used.

isClientKeepAlive

protected abstract boolean isClientKeepAlive()
Indicates if the client wants a persistent connection.

Returns:
True if the client wants a persistent connection.

isConfidential

public boolean isConfidential()
Indicates if the confidentiality of the call is ensured (ex: via SSL).

Returns:
True if the confidentiality of the call is ensured (ex: via SSL).

isConnectionBroken

public boolean isConnectionBroken(java.lang.Exception exception)
Returns true if the given exception is caused by a broken connection.

Parameters:
exception - The exception to inspect.
Returns:
True if the given exception is caused by a broken connection.

isKeepAlive

protected boolean isKeepAlive()
Indicates if both the client and the server want a persistent connection.

Returns:
True if the connection should be kept alive after the call processing.

isRequestChunked

protected boolean isRequestChunked()
Indicates if the request entity is chunked.

Returns:
True if the request entity is chunked.

isResponseChunked

protected boolean isResponseChunked()
Indicates if the response entity is chunked.

Returns:
True if the response entity is chunked.

isServerKeepAlive

protected abstract boolean isServerKeepAlive()
Indicates if the server wants a persistent connection.

Returns:
True if the server wants a persistent connection.

setClientAddress

protected void setClientAddress(java.lang.String clientAddress)
Sets the client address.

Parameters:
clientAddress - The client address.

setClientPort

protected void setClientPort(int clientPort)
Sets the client port.

Parameters:
clientPort - The client port.

setConfidential

protected void setConfidential(boolean confidential)
Indicates if the confidentiality of the call is ensured (ex: via SSL).

Parameters:
confidential - True if the confidentiality of the call is ensured (ex: via SSL).

setHostDomain

public void setHostDomain(java.lang.String hostDomain)
Sets the host domain name.

Parameters:
hostDomain - The baseRef domain name.

setHostPort

public void setHostPort(int hostPort)
Sets the host port.

Parameters:
hostPort - The host port.

setMethod

protected void setMethod(java.lang.String method)
Sets the request method.

Parameters:
method - The request method.

setProtocol

public void setProtocol(Protocol protocol)
Sets the exact protocol used (HTTP or HTTPS).

Parameters:
protocol - The protocol.

setReasonPhrase

public void setReasonPhrase(java.lang.String reasonPhrase)
Sets the reason phrase.

Parameters:
reasonPhrase - The reason phrase.

setRequestUri

protected void setRequestUri(java.lang.String requestUri)
Sets the full request URI.

Parameters:
requestUri - The full request URI.

setServerAddress

public void setServerAddress(java.lang.String responseAddress)
Sets the response address.
Corresponds to the IP address of the responding server.

Parameters:
responseAddress - The response address.

setServerPort

public void setServerPort(int serverPort)
Sets the server port.

Parameters:
serverPort - The server port.

setStatusCode

public void setStatusCode(int code)
Sets the status code.

Parameters:
code - The status code.

setVersion

public void setVersion(java.lang.String version)
Sets the protocol version used.

Parameters:
version - The protocol version used.


Copyright © 2005-2008 Noelios Technologies.