public class Connection extends Object implements ThreadPool.InterruptableTask, ServerStreamConnection
Constructor and Description |
---|
Connection(WebServer pWebServer,
XmlRpcStreamServer pServer,
Socket pSocket)
Creates a new webserver connection on the given socket.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection, and frees resources.
|
InputStream |
newInputStream()
Returns the connections input stream.
|
OutputStream |
newOutputStream()
Returns the connections output stream.
|
void |
run()
Performs the task.
|
void |
setResponseHeader(String pHeader,
String pValue)
Sets a response header value.
|
void |
shutdown()
Interrupts the task.
|
void |
writeError(RequestData pData,
Throwable pError,
ByteArrayOutputStream pStream)
Writes an error response to the output stream.
|
void |
writeErrorHeader(RequestData pData,
Throwable pError,
int pContentLength)
Writes an error responses headers to the output stream.
|
void |
writeResponse(RequestData pData,
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.
|
public Connection(WebServer pWebServer, XmlRpcStreamServer pServer, Socket pSocket) throws IOException
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.IOException
public void run()
ThreadPool.Task
run
in interface ThreadPool.Task
public void writeResponse(RequestData pData, OutputStream pBuffer) throws IOException
pData
- The request data.pBuffer
- The ByteArrayOutputStream
holding the response.IOException
- Writing the response failed.public void writeResponseHeader(RequestData pData, int pContentLength) throws IOException
pData
- The request datapContentLength
- The content length, if known, or -1.IOException
- Writing the response failed.public void writeError(RequestData pData, Throwable pError, ByteArrayOutputStream pStream) throws IOException
pData
- The request data.pError
- The error being reported.pStream
- The ByteArrayOutputStream
with the error response.IOException
- Writing the response failed.public void writeErrorHeader(RequestData pData, Throwable pError, int pContentLength) throws IOException
pData
- The request data.pError
- The error being reported.pContentLength
- The response length, if known, or -1.IOException
- Writing the response failed.public void setResponseHeader(String pHeader, String pValue)
public OutputStream newOutputStream() throws IOException
ServerStreamConnection
newOutputStream
in interface ServerStreamConnection
IOException
public InputStream newInputStream() throws IOException
ServerStreamConnection
newInputStream
in interface ServerStreamConnection
IOException
public void close() throws IOException
ServerStreamConnection
close
in interface ServerStreamConnection
IOException
public void shutdown() throws Throwable
ThreadPool.InterruptableTask
shutdown
in interface ThreadPool.InterruptableTask
Throwable
- Shutting down the task failed.Copyright © 2001-2014 The Apache Software Foundation. All Rights Reserved.