fix(http1): close client after completed response by zfaustk · Pull Request #4179 · hyperium/hyper · GitHub
Skip to content

fix(http1): close client after completed response - #4179

Open
zfaustk wants to merge 1 commit into
hyperium:masterfrom
zfaustk:zfaustk/t-002-hyper-4176
Open

fix(http1): close client after completed response#4179
zfaustk wants to merge 1 commit into
hyperium:masterfrom
zfaustk:zfaustk/t-002-hyper-4176

Conversation

@zfaustk

@zfaustk zfaustk commented Aug 30, 2026

Copy link
Copy Markdown

Closes #4176

Motivation

When an HTTP/1 client receives a complete response while its request body is
still being written, the connection can remain parked in
(Reading::KeepAlive, Writing::Body). The response has completed, but the
connection is neither reusable nor closed, so pooled clients can leak sockets.

Solution

Close this terminal client state in State::try_keep_alive. The transition is
guarded with T::is_client() because the same state shape is valid while a
server is still streaming its response. Regression tests cover both roles:
clients close and servers retain the streaming body.

The close-vs-drain choice follows the issue's terminal-outcome contract: a
client that has already received a complete response cannot safely reuse the
connection while its request body is unfinished. I am happy to adjust this to
a drain policy if maintainers prefer that semantics.

Tests

  • cargo test --features full --lib (117 passed, 6 ignored)
  • deterministic client reproducer: unchanged master fails; this commit
    closes the connection
  • server streaming harness: delayed response chunks remain intact
  • rustfmt --check --edition 2021 src/proto/h1/conn.rs
  • git diff --check

AI assistance was used for code navigation and test drafting. The patch,
reproduction, and verification were reviewed by the author and an independent
non-author agent. Full cross-platform CI remains to be run by GitHub.

Close a client connection when a complete response arrives while the request body is still pending. This avoids parking the connection in a non-reusable terminal state.

Closes hyperium#4176
@seanmonstar

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants