Skip to content

fix(http2): send a ready final body chunk without waiting for capacity - #4279

Open
taradepan wants to merge 2 commits into
hyperium:masterfrom
taradepan:fix/h2-final-chunk-single-write
Open

taradepan wants to merge 2 commits into
hyperium:masterfrom
taradepan:fix/h2-final-chunk-single-write

Conversation

@taradepan

@taradepan taradepan commented Nov 21, 2026 •

Copy link
Copy Markdown

Closes #4241

It fixes the issue. Now the socket writes only once instead of twice. It was sending the header first and the body later; now it sends both of them together.

I ran the full cargo test suite, including my new test, cargo fmt and cargo clippy.

When a request body yields its only chunk immediately (e.g. `Full<Bytes>`),
PipeToSendStream reserved capacity and waited for it before queueing the
data. On a newly opened stream the capacity is assigned only after the
connection task has flushed HEADERS, so HEADERS and DATA were written to
the socket separately.

The final chunk is already in memory and nothing is polled after it, so
waiting adds no backpressure, and h2 buffers `send_data` regardless of
the available capacity. Queue it right away so HEADERS and DATA leave in
a single write.

Closes hyperium#4241

This branch has not been deployed

No deployments
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.

HTTP/2 client sends HEADERS and an immediately ready Full body in separate socket writes

1 participant