org.apache.xmlrpc.webserver
Class Connection

java.lang.Object
  extended by org.apache.xmlrpc.webserver.Connection
All Implemented Interfaces:
ThreadPool.Task

public class Connection
extends java.lang.Object
implements ThreadPool.Task

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, java.net.Socket pSocket)
          Creates a new webserver connection on the given socket.
 
Method Summary
 java.io.InputStream getInputStream(RequestData pData)
          Returns the contents input stream.
 java.io.OutputStream getOutputStream(XmlRpcStreamRequestConfig pConfig)
          Returns the output stream for writing the response.
 void run()
          Performs the task.
 void writeError(RequestData pData, java.lang.Throwable pError, java.io.OutputStream pStream)
          Writes an error response to the output stream.
 void writeErrorHeader(RequestData pData, java.lang.Throwable pError, int pContentLength)
          Writes an error responses headers to the output stream.
 void writeResponse(RequestData pData, java.io.OutputStream pBuffer)
          Writes the response header and the response to the output stream.
 void writeResponseHeader(RequestData pData, int pContentLength)
          Writes the response header to the output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connection

public Connection(WebServer pWebServer,
                  XmlRpcStreamServer pServer,
                  java.net.Socket pSocket)
           throws java.io.IOException
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:
java.io.IOException
Method Detail

run

public void run()
Description copied from interface: ThreadPool.Task
Performs the task.

Specified by:
run in interface ThreadPool.Task

getInputStream

public java.io.InputStream getInputStream(RequestData pData)
Returns the contents input stream.

Parameters:
pData - The request data
Returns:
The contents input stream.

getOutputStream

public java.io.OutputStream getOutputStream(XmlRpcStreamRequestConfig pConfig)
Returns the output stream for writing the response.

Parameters:
pConfig - The request configuration.
Returns:
The response output stream.

writeResponse

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

Parameters:
pData - The request data.
pBuffer - The ByteArrayOutputStream holding the response.
Throws:
java.io.IOException - Writing the response failed.

writeResponseHeader

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

Parameters:
pData - The request data
pContentLength - The content length, if known, or -1.
Throws:
java.io.IOException - Writing the response failed.

writeError

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

Parameters:
pData - The request data.
pError - The error being reported.
pStream - The ByteArrayOutputStream with the error response.
Throws:
java.io.IOException - Writing the response failed.

writeErrorHeader

public void writeErrorHeader(RequestData pData,
                             java.lang.Throwable pError,
                             int pContentLength)
                      throws java.io.IOException
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:
java.io.IOException - Writing the response failed.


Copyright 2001-2001-2006 Apache Software Foundation. All Rights Reserved.