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;
|
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();
|
||||||
|
|
|
@ -398,6 +398,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;
|
||||||
|
@ -424,7 +433,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue