Repository navigation
Do not process HTTP/2 request trailer fields as request headers - #1267
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
The merged cookie request header was added again when the end of the trailer fields was received, so the application saw the cookie header twice. An allowed cookie trailer field was appended to the merged cookie value and so merged into the request header section rather than being exposed as a trailer field. Other allowed trailer fields with dedicated handling (host, priority, expect) also changed request state. All of this happened on the connection thread after the request had been passed to a container thread. Add allowed trailer fields directly to the trailer fields and skip the end of request headers processing for the trailer section.
arturobernalg
force-pushed
the
h2-trailer-cookie
branch
from
November 22, 2026 16:16
11aac8b to
f4924c7
Compare
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.
When an HTTP/2 request has trailer fields,
Stream.receivedEndOfHeaders()runs again at the end of the trailer section and adds the mergedcookieheader a second time, so the application sees twocookieheaders. An allowedcookietrailer field (allowedTrailerHeaders="cookie") is appended to the merged request cookie instead of being exposed as a trailer field, which RFC 9110, section 6.5.1 does not allow. Allowedhost,priorityandexpecttrailer fields also go through the request header handling. All of this happens on the connection thread after the request has been passed to a container thread.Allowed trailer fields are now added directly to the trailer fields, and the end of headers processing is skipped for the trailer section.
Testing:
TestStream.testCookieHeaderWithTrailersandtestCookieTrailerAllowed. On main the cookie headers are[a=1; b=2, a=1; b=2], and[a=1; b=2, a=1; b=2; c=3]with nocookietrailer field. With the fix they are[a=1; b=2], and thecookietrailer field isc=3.org.apache.coyote.http2tests pass.