org.apache.xmlrpc.webserver

Class Connection

public class Connection extends Object implements ThreadPool.Task, ServerStreamConnection

Handler for a single clients connection. This implementation is able to do HTTP keepalive. In other words, it can serve multiple requests via a single, physical connection.
Constructor Summary
Connection(WebServer pWebServer, XmlRpcStreamServer pServer, Socket pSocket)
Creates a new webserver connection on the given socket.
Method Summary
voidclose()
InputStreamnewInputStream()
OutputStreamnewOutputStream()
voidrun()
voidsetResponseHeader(String pHeader, String pValue)
Sets a response header value.
voidwriteError(RequestData pData, Throwable pError, OutputStream pStream)
Writes an error response to the output stream.
voidwriteErrorHeader(RequestData pData, Throwable pError, int pContentLength)
Writes an error responses headers to the output stream.
voidwriteResponse(RequestData pData, OutputStream pBuffer)
Writes the response header and the response to the output stream.
voidwriteResponseHeader(RequestData pData, int pContentLength)
Writes the response header to the output stream.

Constructor Detail

Connection

public Connection(WebServer pWebServer, XmlRpcStreamServer pServer, Socket pSocket)
Creates a new webserver connection on the given socket.

Parameters: pWebServer The webserver maintaining this connection. pServer The server being used to execute requests. pSocket The server socket to handle; the Connection is responsible for closing this socket.

Throws: IOException

Method Detail

close

public void close()

newInputStream

public InputStream newInputStream()

newOutputStream

public OutputStream newOutputStream()

run

public void run()

setResponseHeader

public void setResponseHeader(String pHeader, String pValue)
Sets a response header value.

writeError

public void writeError(RequestData pData, Throwable pError, OutputStream pStream)
Writes an error response to the output stream.

Parameters: pData The request data. pError The error being reported. pStream The {@link ByteArrayOutputStream} with the error response.

Throws: IOException Writing the response failed.

writeErrorHeader

public void writeErrorHeader(RequestData pData, Throwable pError, int pContentLength)
Writes an error responses headers to the output stream.

Parameters: pData The request data. pError The error being reported. pContentLength The response length, if known, or -1.

Throws: IOException Writing the response failed.

writeResponse

public void writeResponse(RequestData pData, OutputStream pBuffer)
Writes the response header and the response to the output stream.

Parameters: pData The request data. pBuffer The {@link ByteArrayOutputStream} holding the response.

Throws: IOException Writing the response failed.

writeResponseHeader

public void writeResponseHeader(RequestData pData, int pContentLength)
Writes the response header to the output stream. *

Parameters: pData The request data pContentLength The content length, if known, or -1.

Throws: IOException Writing the response failed.

Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.