Skip to content

fix(http2): strip TE request header when any value is not trailers - #4194

Open
Dev-next-gen wants to merge 1 commit into
hyperium:masterfrom
Dev-next-gen:fix/h2-te-repeated-values
Open

Dev-next-gen wants to merge 1 commit into
hyperium:masterfrom
Dev-next-gen:fix/h2-te-repeated-values

Conversation

@Dev-next-gen

Copy link
Copy Markdown

After #4152 made the HTTP/1 side look at every TE line and every token, I checked the HTTP/2 path and found that strip_connection_headers still only reads the first TE value before sending a request. With TE: trailers followed by a second line like TE: gzip, the first value passes, nothing gets stripped, and h2's own send check also only looks at the first value, so both lines go out. The receiving side validates each field on its own, so the peer resets the stream with PROTOCOL_ERROR. Between two hyper peers, send_request returns Reset(StreamId(1), PROTOCOL_ERROR, Remote).

The fix checks every TE value, and if any of them is not trailers the header is removed, which is what already happens when a single TE value is not trailers. Requests that worked before (no TE, or one TE: trailers) behave the same. The only requests that change are the ones that were always reset.

I added an integration test with a hyper h2 client and server. It fails on master with the reset above and passes with the change. The integration, lib, client and server test suites pass locally with --features full, as do cargo fmt --check and cargo clippy --features full.

AI tools used

Only the first TE value was checked before sending an HTTP/2 request, so a
request with `TE: trailers` followed by another TE line kept both values
and the peer reset the stream with PROTOCOL_ERROR. Check every value, as
the HTTP/1 side already does since hyperium#4152.
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