Skip to content

fix(http1): allow keep-alive for chunked requests with trailers#4043

Merged
seanmonstar merged 2 commits intohyperium:masterfrom
wi-adam:fix/chunked-trailer-keep-alive
Mar 27, 2026
Merged

fix(http1): allow keep-alive for chunked requests with trailers#4043
seanmonstar merged 2 commits intohyperium:masterfrom
wi-adam:fix/chunked-trailer-keep-alive

Conversation

@wi-adam
Copy link
Copy Markdown
Contributor

@wi-adam wi-adam commented Mar 26, 2026

Summary

  • When a chunked request body included trailers, poll_read_body in conn.rs incorrectly transitioned to Reading::Closed instead of Reading::KeepAlive, preventing connection reuse.
  • Trailers signal body completion (same as a final data frame at EOF), so the connection should remain eligible for keep-alive.
  • Added a regression test that sends a chunked POST with trailers, then verifies the connection is reused by sending a second request on the same TCP stream.

Test plan

  • New test http1_trailer_recv_keep_alive passes with fix
  • New test fails without fix (ConnectionReset on second request)
  • Full test suite passes (cargo test --features full — 271 tests, 0 failures)
  • rustfmt clean
  • No dead_code or unused_imports warnings

wi-adam added 2 commits March 26, 2026 10:14
When a chunked request body included trailers, poll_read_body
incorrectly transitioned to Reading::Closed instead of
Reading::KeepAlive. This prevented connection reuse for any request
that sent trailers, even though trailers signal body completion just
like a final data frame at EOF.

Closes #4039
Copy link
Copy Markdown
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm so glad the fix was so simple. Thanks for fixing this, and for adding a test, much appreciated!

@seanmonstar seanmonstar merged commit 7211ec2 into hyperium:master Mar 27, 2026
22 checks passed
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.

2 participants