Skip to content

QUIC: Read data and get end notification together #55707

@JamesNK

Description

@JamesNK

There doesn't seem to be an API on QuicStream that allows you to read data and get a notification that it is the final chunk of data in one operation.

An API for writing data and ending a stream together exists:

await stream.WriteAsync(data, endStream: true);

But for reading you must always get data and then read again to get a result of 0 which means no more data:

var buffer = GetBuffer();
while (true)
{
    var readCount = await stream.ReadAsync(buffer);
    if (readCount == 0) break;

    // Do stuff with data but don't know whether it is the final data.
}

I think this might be required for Kestrel to properly support HEADERS only requests.

When Kestrel gets the first HEADER frame it needs to start the request. But it also needs to know whether it or not is it ONLY a HEADERS request. If the stream data ends with the HEADERS frame then we process it differently than if the stream is still going and there are DATA frames still to come.

Kestrel can't hang around, waiting on the next QuicStream.ReadAsync to return 0 or a value before it starts the request. That data might be a long time coming (e.g. a long-running gRPC stream where the client doesn't send a message on the stream until 1 minute later)

I think we need ReadAsync to return something like ReadResult. ReadResult has data on it (it could be a data length if you prefer), AND a flag saying whether we are done or not.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions