super.handleRequest();
}
public Connection handle() throws IOException
{
Connection connection = this;
try
{
setCurrentConnection(this);
// do while the endpoint is open
// AND the connection has not changed
while (_endp.isOpen() && connection==this)
{
try
{
// If we are not ended then parse available
if (!_parser.isComplete() && !_endp.isInputShutdown())
_parser.parseAvailable();
// Do we have more generating to do?
// Loop here because some writes may take multiple steps and
// we need to flush them all before potentially blocking in the
// next loop.
if (_generator.isCommitted() && !_generator.isComplete() && !_endp.isOutputShutdown())
_generator.flushBuffer();
// Flush buffers
_endp.flush();
}
catch (HttpException e)
{
if (LOG.isDebugEnabled())
{
LOG.debug("uri="+_uri);
LOG.debug("fields="+_requestFields);
LOG.debug(e);
}
_generator.sendError(e.getStatus(), e.getReason(), null, true);
_parser.reset();
_endp.shutdownOutput();
}
finally
{
// Is this request/response round complete and are fully flushed?
if (_parser.isComplete() && _generator.isComplete())
{
// Reset the parser/generator
reset();
// look for a switched connection instance?
if (_response.getStatus()==HttpStatus.SWITCHING_PROTOCOLS_101)
{
Connection switched=(Connection)_request.getAttribute("org.eclipse.jetty.io.Connection");
if (switched!=null)
connection=switched;
}
// TODO Is this required?