Skip to content

fix: preserve HTTP/2 response trailers with an empty entity - #1678

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:fix/http2-empty-response-trailers
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:fix/http2-empty-response-trailers

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 26, 2026

Copy link
Copy Markdown
Member

Motivation

A normal HTTP/2 server response can carry application-provided trailers even when it has no body data. The server previously ended an empty response in its initial headers and omitted the trailers.

Modification

Keep a successful empty response with actual application trailers open until the trailing header block is sent. Reuse the existing trailer rendering and stream completion. Preserve existing termination for HEAD, no-content statuses, or responses without trailers.

Result

A normal empty response sends initial headers followed by terminal trailing headers, with no DATA frame needed. Nonempty responses and the client request path retain their existing behavior.

Tests

  • JDK 17 with Scala 2.13.18 and 3.3.9: eight focused Netty-independent native Pekko HTTP server-stage cases passed on each version using the exact changed sources with cached support.
  • The new normal 200 response case failed on the old implementation as expected. Scoped Scalafmt and git diff --check passed. Full CI was not verified before opening.

References

Motivation:
An otherwise valid server response could end its stream in the initial headers before application-provided trailers were sent.

Modification:
Keep normal empty responses with nonempty application trailers open until the trailer block is written. Preserve existing termination for HEAD, bodyless status codes, and responses without trailers.

Result:
The server sends initial headers followed by trailing headers without requiring a DATA frame. Existing body handling and client behavior are unchanged.

References:
RFC 9113 Section 8.1; Apache Pekko HTTP Trailer API.
@He-Pin
He-Pin requested a review from pjfanning November 26, 2026 22:26
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.

1 participant