Skip to content

Chunked request with trailers incorrectly closes connection instead of keeping alive #4044

@wi-adam

Description

@wi-adam

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions