Issue #6728 - QUIC and HTTP/3

- Fixed trailer frame handling.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2021-11-02 17:27:31 +01:00
parent 6aedfe52f1
commit cb97549fa6
2 changed files with 29 additions and 12 deletions

View File

@ -197,17 +197,26 @@ public abstract class HTTP3StreamConnection extends AbstractConnection
{ {
case FRAME: case FRAME:
{ {
DataFrame frame = dataFrame; if (parserDataMode)
dataFrame = null; {
if (LOG.isDebugEnabled()) DataFrame frame = dataFrame;
LOG.debug("read data {} on {}", frame, this); dataFrame = null;
buffer.retain(); if (LOG.isDebugEnabled())
// Store in a local variable so that the lambda captures the right buffer. LOG.debug("read data {} on {}", frame, this);
RetainableByteBuffer current = buffer; buffer.retain();
// Release the network buffer here (if empty), since the application may // Store in a local variable so that the lambda captures the right buffer.
// not be reading more bytes, to avoid to keep around a consumed buffer. RetainableByteBuffer current = buffer;
tryReleaseBuffer(false); // Release the network buffer here (if empty), since the application may
return new Stream.Data(frame, () -> completeReadData(current)); // not be reading more bytes, to avoid to keep around a consumed buffer.
tryReleaseBuffer(false);
return new Stream.Data(frame, () -> completeReadData(current));
}
else
{
// Not anymore in data mode, so it's a trailer frame.
tryReleaseBuffer(false);
return null;
}
} }
case MODE_SWITCH: case MODE_SWITCH:
{ {

View File

@ -368,7 +368,15 @@ public class HttpChannelOverHTTP3 extends HttpChannel
return result; return result;
} }
return null; else
{
// The call to readData() may have parsed the trailer frame which
// triggers the content complete event which sets the content to EOF.
try (AutoLock l = lock.lock())
{
return content;
}
}
} }
private HttpInput.Content newContent(Stream.Data data) private HttpInput.Content newContent(Stream.Data data)