quiche icon indicating copy to clipboard operation
quiche copied to clipboard

h3: add support for streaming HEADERS with new sequence

Open LPardue opened this issue 3 months ago • 1 comments

Calls to send_request(), send_response(), send_response_with_priority(), and send_additional_headers() can fail with a StreamBlocked error indicating lack of underlying transport capacity. When this occurs, applications are expected to retry the operation when the stream is later reported as writable.

However, certain conditions could mean that sufficient capacity might never be made available, effectively permenantly blocking header sends. The root cause of this problem was the choice to enforce that a HEADERS frame is always sent (buffered into a quiche stream) in whole.

This change adds new functions related to stream management and header sending to support a streaming send design. These will produce a HEADERS frame that can be sent in whole or in part, depending on available capacity. When a frame is only partly sent, applications are notified and can resume sending using the new continue_partial_headers() method, once the stream is writable.

The new functions unify how clients and servers send headers. For a client, the expected sequence is now something like:

  1. Decide to initate a request
  2. reserve_request_stream() - reserves a stream if limits allow
  3. stream_headers() - inititates streaming of a HEADERS frame
  4. continue_partial_headers() - if stream_headers() returned Error::PartialHeader

For a server, the expected sequence is now something like:

  1. Receive a request via the poll() function and decide to respond
  2. stream_priority() - set the stream's sending priority per RFC 9218
  3. stream_headers() - inititates streaming of a HEADERS frame
  4. continue_partial_headers() - if stream_headers return Error::PartialHeader

While headers are being streamed, other operations that would cause an HTTP/3 frame to be sent on the stream are prevented. HEADERS frames must be sent completely before other operations are successful.

Applications do not need to manage the partial HEADERS buffer, this is dealt with inside quiche.

Co-authored-by: Gregor Maier [email protected]

LPardue avatar Sep 09 '25 03:09 LPardue

Still needs a bit more testing / hardening but is ready for initial review

LPardue avatar Sep 09 '25 12:09 LPardue