Skip to content

net.http: support streaming response callbacks and stop limits over HTTP/2 #27368

Description

@quaesitor-scientiam

Summary

The HTTP/2 fetch path added in #27362 buffers the entire response body before
returning. As a result, requests that rely on streaming response behaviour are
not served over HTTP/2 — to avoid silently ignoring them, such requests
currently fall back to HTTP/1.1 (they do not advertise ALPN h2). This issue
tracks adding real streaming support so HTTP/2 reaches parity.

Affected request features (all currently force HTTP/1.1 via
Request.uses_response_streaming()):

  • on_progress (RequestProgressFn)
  • on_progress_body (RequestProgressBodyFn)
  • stop_copying_limit
  • stop_receiving_limit

(on_finish already works on the HTTP/2 path.)

What's needed

Feed the per-DATA-frame body chunks from H2Conn's response read loop
(read_response in vlib/net/http/h2_conn.v) into the same callbacks, and
honor the stop limits, matching the HTTP/1.1 semantics in
receive_all_data_from_cb_in_builder:

  • call on_progress / on_progress_body per chunk as DATA frames arrive,
  • stop_copying_limit: stop appending to the response body after N bytes while
    still firing callbacks and reading to completion,
  • stop_receiving_limit: stop reading the stream early.

Likely shape: thread a generic chunk hook + the two limits through
H2ClientRequest (keeping H2Conn decoupled from net.http.Request), and have
the shim (h2_do in backend.c.v) adapt the request's callbacks to it. Then
drop the uses_response_streaming() gate so these requests can negotiate h2.

Acceptance criteria

  • on_progress / on_progress_body fire per DATA frame on the HTTP/2 path.
  • stop_copying_limit / stop_receiving_limit behave as on HTTP/1.1.
  • Streaming requests with enable_http2: true negotiate h2 (gate removed).
  • Tests over the in-memory transport assert chunk-by-chunk callback delivery and
    the stop-limit behaviour; a large download_file_with_progress-style case.

References

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions