Skip to content

Bump h2 to ~>0.10.0 and add HTTP/2 streaming bodies - #875

Merged
benoitc merged 1 commit into
masterfrom
feature/http2-streaming-bodies
Jun 13, 2026
Merged

Bump h2 to ~>0.10.0 and add HTTP/2 streaming bodies#875
benoitc merged 1 commit into
masterfrom
feature/http2-streaming-bodies

Conversation

@benoitc

@benoitc benoitc commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Loosen the h2 requirement from a pinned 0.9.0 to ~>0.10.0 so all patched 0.10 releases are accepted without re-bumping.

Add HTTP/2 support to the existing streaming API so it reaches parity with HTTP/1.1 and HTTP/3. With body = stream, the request body is sent in DATA frames via send_body/2 + finish_send_body/1, and the response is read with start_response/1 then body/1 or stream_body/1. The change is additive: every new clause is guarded on protocol = http2 and the one-shot path is untouched.

Two fixes were needed along the way:

  • streaming_body(enter,...) set the socket to passive, but for h2 the h2_connection process owns the socket and reads it in active mode, so responses never arrived. The h2 enter clause now skips the setopts.
  • The streaming_body -> connected transition re-armed the pool keepalive timer that http/2 sometimes hangs #836 cancels for h2, which could tear down a slow streaming response. The transition now cancels it, same as start_h2_connection.

Tests in test/hackney_http2_streaming_tests.erl cover a large streamed request echoed back intact, an empty streamed body, chunk-by-chunk response reads, and a one-shot regression guard.

Loosen the h2 requirement from a pinned 0.9.0 to ~>0.10.0 so all patched
0.10 releases are accepted without re-bumping each time.

Add HTTP/2 support to the existing streaming API so it reaches parity with
HTTP/1.1 and HTTP/3: body = stream then send_body/finish_send_body/
start_response/body/stream_body now stream the request body in DATA frames
and read the response in full or chunk by chunk. The change is additive,
every new clause is guarded on protocol = http2 and the one-shot path is
untouched.

Two fixes were needed for the streaming path: skip the streaming_body
passive-socket setopts for h2 (the h2_connection process owns the socket
and reads it in active mode), and cancel the pool keepalive timer on the
streaming_body to connected transition so a slow streaming response is not
torn down (same invariant as #836).
@benoitc
benoitc merged commit 66c0c26 into master Jun 13, 2026
6 checks passed
@benoitc
benoitc deleted the feature/http2-streaming-bodies branch June 13, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant