* Issue #2970 ensure onComplete is called * Cleanup after review - single try Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
edc47818e2
commit
efdf3c2473
|
@ -481,33 +481,38 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
|||
|
||||
case COMPLETE:
|
||||
{
|
||||
if (!_response.isCommitted() && !_request.isHandled())
|
||||
try
|
||||
{
|
||||
_response.sendError(HttpStatus.NOT_FOUND_404);
|
||||
}
|
||||
else
|
||||
{
|
||||
// RFC 7230, section 3.3.
|
||||
int status = _response.getStatus();
|
||||
boolean hasContent = !(_request.isHead() ||
|
||||
if (!_response.isCommitted() && !_request.isHandled())
|
||||
{
|
||||
_response.sendError(HttpStatus.NOT_FOUND_404);
|
||||
}
|
||||
else
|
||||
{
|
||||
// RFC 7230, section 3.3.
|
||||
int status = _response.getStatus();
|
||||
boolean hasContent = !(_request.isHead() ||
|
||||
HttpMethod.CONNECT.is(_request.getMethod()) && status == HttpStatus.OK_200 ||
|
||||
HttpStatus.isInformational(status) ||
|
||||
status == HttpStatus.NO_CONTENT_204 ||
|
||||
status == HttpStatus.NOT_MODIFIED_304);
|
||||
if (hasContent && !_response.isContentComplete(_response.getHttpOutput().getWritten()))
|
||||
{
|
||||
if (isCommitted())
|
||||
abort(new IOException("insufficient content written"));
|
||||
else
|
||||
_response.sendError(HttpStatus.INTERNAL_SERVER_ERROR_500,"insufficient content written");
|
||||
if (hasContent && !_response.isContentComplete(_response.getHttpOutput().getWritten()))
|
||||
{
|
||||
if (isCommitted())
|
||||
abort(new IOException("insufficient content written"));
|
||||
else
|
||||
_response.sendError(HttpStatus.INTERNAL_SERVER_ERROR_500, "insufficient content written");
|
||||
}
|
||||
}
|
||||
_response.closeOutput();
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
_request.setHandled(true);
|
||||
_state.onComplete();
|
||||
onCompleted();
|
||||
}
|
||||
_response.closeOutput();
|
||||
_request.setHandled(true);
|
||||
|
||||
_state.onComplete();
|
||||
|
||||
onCompleted();
|
||||
|
||||
break loop;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue