Avoid redundant HTTP/2 header name validation#2275
Open
pavel-ptashyts wants to merge 1 commit into
Open
Conversation
HTTP/2 decoding already validates response header names. Rechecking them while converting to HttpHeaders repeats per-character work for every response and trailer. Use a factory that disables only name validation while preserving value validation, including CR/LF rejection. Cover both properties with focused tests. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
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.
Summary
Motivation
The HTTP/2 decoder already validates response header names, but
Http2Handlerrebuilt every response and trailer withnew DefaultHttpHeaders(), repeating the per-character name scan. The decoder does not enable value validation by default, so disabling all validation during the copy would introduce a CR/LF injection regression.This change uses an immutable
DefaultHttpHeadersFactoryconfigured to skip only name validation. Value validation remains enabled.Validation
./mvnw -pl client -Dtest=org.asynchttpclient.netty.handler.Http2HandlerTest testBasicHttp2Test#configRequestTimeoutHappensInDueTimeOverHttp2was excluded from the second command after its wall-clock assertion produced unstable measurements of -17 ms and 1707 ms while the timeout log reported expiration after 1052 ms. No timeout code is changed by this PR.The local environment only provides JDK 21. The JDK 11
./mvnw clean verifygate was not run locally; the repository CI matrix provides JDK 11 coverage.Attribution
Codex on behalf of Pavel Ptashyts