Repository navigation
Normalize outgoing HTTP/2 initial fields - #1463
Merged
Merged
Conversation
pjfanning
reviewed
Nov 17, 2026
pjfanning
left a comment
Member
There was a problem hiding this comment.
Thanks. Dropping Upgrade, Keep-Alive, Proxy-Connection and non-trailers TE from HTTP/2 output is right per RFC 9113 §8.2.2, and keeping the HTTP/1 models usable is the right call. Two points about where the rule lives:
- Two suppression lists.
renderHeadersalready suppressesConnectionandTransfer-Encoding(modeled and raw) with its own warnings.normalizeInitialHeadersnow filters those, plus the new ones, beforerenderHeadersruns. So for initial fields the old branches never fire, but they still apply to trailers, and the two lists can drift apart. Could the new rules go into the existingrenderHeadersmatch instead (including theCustomHeadercase, which currently skips suppression), so there's one list? - Trailers. The comment explains that the pre-filter is limited to initial fields because
renderHeadersalso renders streamed trailers. But §8.2.2 forbids connection-specific fields in any field section, trailers included, so applying the same rule there would be correct rather than a side effect.TEis the one special case: it's only meaningful (astrailers) in request headers, so it should be dropped from trailers entirely. - Docs. The "Initial request fields" / "Initial response fields" sections describe protocol-mandated behaviour. A single line saying that connection-specific headers set on the model are dropped (with a warning) when sent over HTTP/2 would be enough.
Motivation: Connection-specific fields must not be emitted in HTTP/2 field sections. Use one policy for initial headers and trailers, including custom headers. Modification: Consolidate connection-field suppression before the custom-header branch. Use a boolean filter without per-header Option allocation or repeated values. Retain canonical TE trailers only in initial request headers. Apply the same policy to streamed and attribute-supplied trailers. Replace detailed protocol documentation with a short user-facing statement. Result: HTTP/1 models stay usable while HTTP/2 output consistently omits unsupported connection fields. Existing renderHeaders signatures remain unchanged. Tests: - Changed renderer and spec compile with cached Scala 2.13.18 and fatal warnings. - All 34 HttpMessageRenderingSpec model-level tests pass, including initial request/response, custom header, streamed trailer and attribute trailer cases. - Compilation and tests use previously cached HTTP core module classes and dependencies, not a clean exact-main build. No wire or parser scenarios ran. - Cached Scalafmt 3.11.5 reports both Scala files unchanged. - git diff --check passes. Full build, cross-Scala, MiMa and docs build not run. References: Refs apache#1463; RFC 9113 section 8.2.2; pjfanning review.
He-Pin
force-pushed
the
fix/http2-initial-field-normalization
branch
from
November 17, 2026 17:44
7ae2142 to
cae8ca4
Compare
pjfanning
approved these changes
Nov 17, 2026
pjfanning
left a comment
Member
There was a problem hiding this comment.
lgtm. Minor, not blocking: renderHeaders infers isTrailer = !shouldRenderAutoHeaders. That's correct today, since the streamed-trailer call in Http2StreamHandling is the only caller passing false, but an explicit isTrailer parameter would stop a future non-trailer caller from silently losing te: trailers.
This was referenced Nov 18, 2026
pjfanning
added a commit
that referenced
this pull request
Nov 19, 2026
Motivation: HTTP/2 field restrictions apply to initial headers and trailers. Connection-specific fields set as raw or custom headers, or in trailers, were not consistently suppressed. Modification: Share case-insensitive suppression of Connection, Keep-Alive, Proxy-Connection, Transfer-Encoding and Upgrade across modeled, raw and custom fields, retaining TE: trailers only in initial requests. Result: Outbound field sections follow a consistent policy without changing HTTP/1 behavior. Tests: - http2-tests/testOnly HttpMessageRenderingSpec (backport of #1463) References: Backport of #1463 (c6184f0) Co-authored-by: He-Pin(kerr) <[email protected]>
pjfanning
added a commit
that referenced
this pull request
Nov 19, 2026
Motivation: Several recently merged PRs left review points unaddressed: docs that were asked to be dropped, comments and tests that were suggested, and small API and internal tidy-ups. Modification: - Add a Scala FilenameEncoding alias and values to Multipart.FormData and use them in the Scala toEntity signature and tests (#1494). - Render the form-data Content-Disposition header directly instead of rendering it twice and slicing off the prefix (#1494). - Drop the docs paragraph about unpaired URI surrogates (#1426) and the cookie -0000 sentence in request-level.md (#1493). - Fix the javadsl Multipart.FormData doc the same way #1483 fixed the scaladsl one. - Comment the cookie date rule copies so they stay in sync (#1458). - Test custom methods starting with Q next to the QUERY fast path (#1477). - Use one root package import and a dilated timeout in HeaderCompressionSpec (#1438). - Pass isTrailer to HttpMessageRendering.renderHeaders explicitly (#1463). - Remove the unused forwarding overloads in Handshake.Client and EnabledPingState (#1436, #1462). - Move the media type model checks from the routing spec to a new http-core MediaTypesSpec (#1437, #1454). - Hash the WebSocket key without String.valueOf (#1439). Result: The review points are addressed. The only public API change is the added Scala FilenameEncoding alias. Tests: - http-core/testOnly MultipartSpec MultipartsSpec MediaTypesSpec RequestParserCRLFSpec RequestParserLFSpec HeaderCompressionSpec WebSocketClientSpec HeaderSpec HttpHeaderSpec: 314 passed - http2-tests/testOnly HttpMessageRenderingSpec Http2PingSchedulingSpec: 38 passed - http-tests/testOnly FileAndResourceDirectivesSpec: 63 passed - http-core/mimaReportBinaryIssues: passed References: Refs #1426, #1436, #1437, #1438, #1439, #1454, #1458, #1462, #1463, #1477, #1483, #1493, #1494
He-Pin
added a commit
that referenced
this pull request
Nov 28, 2026
Motivation: The positive HTTP/2 request test checks that TE: trailers is accepted, but not that the parsed field is available through typed header lookup. Modification: Give the existing GET fixture an authority and assert that its typed TE header contains exactly the trailers marker. Result: The test now catches a dropped or unmodeled field without introducing another fixture or changing production code. Tests: - Focused RequestParsingSpec case passed on JDK 17 with Scala 2.13.18 and 3.3.9, on unmodified main and published Pekko HTTP 2.0.0. - Scoped scalafmt and git diff --check passed. - The full sbt test suite was not run. References: Refs #1463; RFC 9113 sections 8.2.2 and 8.3.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Shared HTTP models can contain fields intended for HTTP/1. HTTP/2 outbound field sections need a consistent policy for connection-specific fields across initial headers and trailers.
Modification
Result
Initial and trailer HTTP/2 field sections use the same suppression policy without rejecting models shared with HTTP/1. This does not change intermediary forwarding or claim full intermediary compliance.
Tests
34 focused renderer model tests compiled and passed against cached HTTP module classes with Scala 2.13.18 and fatal warnings enabled. Formatter and diff checks passed. Full CI for this exact revision is queued.
The preceding revision recorded 28 HttpMessageRenderingSpec tests, four ordinary HTTP/2 round trips, cross-Scala header checks, documentation generation and targeted MiMa checks. Those historical results are not new full-suite, Scala 3 or MiMa validation of this revision.
References