Package org.restlet.engine.adapter
Class ServerCall
java.lang.Object
org.restlet.engine.adapter.Call
org.restlet.engine.adapter.ServerCall
- Direct Known Subclasses:
HttpExchangeCall
Abstract HTTP server connector call.
- Author:
- Jerome Louvel
-
Constructor Summary
ConstructorsConstructorDescriptionServerCall(String serverAddress, int serverPort) Constructor.ServerCall(Server server) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanabort()Ask the connector to abort the related network connection, for example immediately closing the socket.voidcomplete()Complete the responsevoidFlushes the buffers onto the network so that for example you can force headers to be written before the entity is becoming available.Returns the chain of client SSL certificates, if available and accessible.Returns the SSL Cipher Suite, if available and accessible.protected longReturns the content length of the request entity if know,Representation.UNKNOWN_SIZEotherwise.Returns the host domain name.intReturns the host port.Returns the request entity if available.abstract InputStreamgetRequestEntityStream(long size) Returns the request entity stream if it exists.abstract InputStreamReturns the request head stream if it exists.abstract OutputStreamReturns the response entity stream if it exists.Returns the SSL key size, if available and accessible.Returns the SSL session ID, in hexadecimal encoding, if available and accessible.protected byte[]Returns the SSL session ID, as a byte array, if available and accessible in that format (to be used by getSslSessionId).protected booleanIndicates if the client wants a persistent connection.protected booleanIndicates if the server wants a persistent connection.protected voidreadRequestHead(InputStream headStream) Reads the HTTP request head (request line and headers).voidsendResponse(Response response) Sends the response back to the client.booleanshouldResponseBeChunked(Response response) Indicates if the response should be chunked because its length is unknown.protected voidwriteResponseBody(Representation entity, OutputStream responseEntityStream) Effectively writes the response body.protected voidwriteResponseHead(Response response) Writes the response status line and headers.protected voidwriteResponseHead(Response response, OutputStream headStream) Writes the response head to the given output stream.Methods inherited from class org.restlet.engine.adapter.Call
getClientAddress, getClientPort, getLogger, getMethod, getProtocol, getReasonPhrase, getRepresentation, getRequestHeaders, getRequestUri, getResponseHeaders, getServerAddress, getServerPort, getStatusCode, getUserPrincipal, getVersion, isBroken, isConfidential, isConnectionBroken, isKeepAlive, isRequestChunked, isResponseChunked, setClientAddress, setClientPort, setConfidential, setHostDomain, setHostPort, setMethod, setProtocol, setReasonPhrase, setRequestUri, setServerAddress, setServerPort, setStatusCode, setUserPrincipal, setVersion
-
Constructor Details
-
ServerCall
Constructor.- Parameters:
server- The parent server connector.
-
ServerCall
Constructor.- Parameters:
serverAddress- The server IP address.serverPort- The server port.
-
-
Method Details
-
abort
public abstract boolean abort()Ask the connector to abort the related network connection, for example immediately closing the socket.- Returns:
- True if the connection was aborted.
-
complete
public void complete()Complete the response -
flushBuffers
Flushes the buffers onto the network so that for example you can force headers to be written before the entity is becoming available.- Throws:
IOException
-
getCertificates
Returns the chain of client SSL certificates, if available and accessible.- Returns:
- The chain of client SSL certificates, if available and accessible.
- Throws:
SSLPeerUnverifiedException
-
getCipherSuite
Returns the SSL Cipher Suite, if available and accessible.- Returns:
- The SSL Cipher Suite, if available and accessible.
-
getContentLength
protected long getContentLength()Returns the content length of the request entity if know,Representation.UNKNOWN_SIZEotherwise.- Returns:
- The request content length.
-
getHostDomain
Returns the host domain name.- Overrides:
getHostDomainin classCall- Returns:
- The host domain name.
-
getHostPort
public int getHostPort()Returns the host port.- Overrides:
getHostPortin classCall- Returns:
- The host port.
-
getRequestEntity
Returns the request entity if available.- Returns:
- The request entity if available.
-
getRequestEntityStream
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.
-
getRequestHeadStream
Returns the request head stream if it exists.- Returns:
- The request head stream if it exists.
-
getResponseEntityStream
Returns the response entity stream if it exists.- Returns:
- The response entity stream if it exists.
-
getSslKeySize
Returns the SSL key size, if available and accessible.- Returns:
- The SSL key size, if available and accessible.
-
getSslSessionId
Returns the SSL session ID, in hexadecimal encoding, if available and accessible.- Returns:
- The SSL session ID, in hexadecimal encoding, if available and accessible.
-
getSslSessionIdBytes
protected byte[] getSslSessionIdBytes()Returns the SSL session ID, as a byte array, if available and accessible in that format (to be used by getSslSessionId).- Returns:
- The SSL session ID, as a byte array, if available and accessible in that format.
-
isClientKeepAlive
protected boolean isClientKeepAlive()Description copied from class:CallIndicates if the client wants a persistent connection.- Specified by:
isClientKeepAlivein classCall- Returns:
- True if the client wants a persistent connection.
-
isServerKeepAlive
protected boolean isServerKeepAlive()Description copied from class:CallIndicates if the server wants a persistent connection.- Specified by:
isServerKeepAlivein classCall- Returns:
- True if the server wants a persistent connection.
-
readRequestHead
Reads the HTTP request head (request line and headers).- Throws:
IOException
-
sendResponse
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.- Parameters:
response- The high-level response.- Throws:
IOException- if the Response could not be written to the network.
-
shouldResponseBeChunked
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
protected void writeResponseBody(Representation entity, OutputStream responseEntityStream) 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.responseEntityStream- The response entity stream or null if a channel is used.- Throws:
IOException
-
writeResponseHead
Writes the response status line and headers. Does nothing by default.- Parameters:
response- The response.- Throws:
IOException
-
writeResponseHead
Writes the response head to the given output stream.- Parameters:
response- The response.headStream- The output stream to write to.- Throws:
IOException
-