Release request buffer before handling when there is no content --------- Signed-off-by: Simone Bordet <simone.bordet@gmail.com> Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
e52bd7a9c7
commit
dc43f3d498
|
@ -422,6 +422,11 @@ public class HttpParser
|
|||
return _state;
|
||||
}
|
||||
|
||||
public boolean hasContent()
|
||||
{
|
||||
return _endOfContent != EndOfContent.NO_CONTENT;
|
||||
}
|
||||
|
||||
public boolean inContentState()
|
||||
{
|
||||
return _state.ordinal() >= State.CONTENT.ordinal() && _state.ordinal() < State.END.ordinal();
|
||||
|
|
|
@ -398,6 +398,15 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
|||
if (LOG.isDebugEnabled())
|
||||
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.
|
||||
_handling.set(true);
|
||||
Runnable onRequest = _onRequest;
|
||||
|
@ -424,9 +433,17 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
|||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("upgraded {} -> {}", this, getEndPoint().getConnection());
|
||||
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;
|
||||
}
|
||||
}
|
||||
else if (filled == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue