Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.1.x

This commit is contained in:
gregw 2024-09-18 07:17:52 +10:00
commit a6125e40f0
2 changed files with 23 additions and 1 deletions

View File

@ -422,6 +422,11 @@ public class HttpParser
return _state; return _state;
} }
public boolean hasContent()
{
return _endOfContent != EndOfContent.NO_CONTENT;
}
public boolean inContentState() public boolean inContentState()
{ {
return _state.ordinal() >= State.CONTENT.ordinal() && _state.ordinal() < State.END.ordinal(); return _state.ordinal() >= State.CONTENT.ordinal() && _state.ordinal() < State.END.ordinal();

View File

@ -405,6 +405,15 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("HANDLE {} {}", request, this); LOG.debug("HANDLE {} {}", request, this);
// If the buffer is empty and no body is expected, then release the buffer
if (isRequestBufferEmpty() && !_parser.hasContent())
{
// try parsing now to the end of the message
parseRequestBuffer();
if (_parser.isComplete())
releaseRequestBuffer();
}
// Handle the request by running the task. // Handle the request by running the task.
_handling.set(true); _handling.set(true);
Runnable onRequest = _onRequest; Runnable onRequest = _onRequest;
@ -431,7 +440,15 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("upgraded {} -> {}", this, getEndPoint().getConnection()); LOG.debug("upgraded {} -> {}", this, getEndPoint().getConnection());
releaseRequestBuffer(); if (_requestBuffer != null)
releaseRequestBuffer();
break;
}
// If we have already released the request buffer, then use fill interest before allocating another
if (_requestBuffer == null)
{
fillInterested();
break; break;
} }
} }