-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Bug Description
When an HTTP/1.1 chunked request body includes trailers, the connection is closed instead of being kept alive for reuse.
Root Cause
In src/proto/h1/conn.rs, poll_read_body transitions to Reading::Closed when a trailers frame is received (line 396). It should transition to Reading::KeepAlive, matching the behavior for a completed data frame at EOF (line 378). Both cases indicate body completion, but only the data path allows connection reuse.
This causes try_keep_alive() to close the connection when it sees Reading::Closed, preventing any subsequent request on the same connection.
Reproduction
Send a chunked POST with trailers on a keep-alive connection, then attempt to send a second request.
client > server
POST / HTTP/1.1
trailer: chunky-trailer
host: example.domain
transfer-encoding: chunked
5
hello
0
chunky-trailer: header data
server > client
HTTP/1.1 200 OK
content-length: 2
date: Thu, 26 Mar 2026 17:30:47 GMT
ok
client > server
GET /quux HTTP/1.1 ← second request, reusing connection
Host: example.domain
Connection: close
server > client
[FIN] connection closed ← bug: server closed instead of responding
Without trailers, the same sequence works correctly and the second request receives a response.
Fix
PR #4043