Skip to content

Avoid redundant HTTP/2 header name validation#2275

Open
pavel-ptashyts wants to merge 1 commit into
AsyncHttpClient:mainfrom
maygemdev:perf/http2-response-header-validation
Open

Avoid redundant HTTP/2 header name validation#2275
pavel-ptashyts wants to merge 1 commit into
AsyncHttpClient:mainfrom
maygemdev:perf/http2-response-header-validation

Conversation

@pavel-ptashyts

Copy link
Copy Markdown
Contributor

Summary

  • create HTTP/2 response and trailer containers with header-name validation disabled
  • preserve Netty's default header-value validation, including CR/LF rejection
  • centralize pseudo-header filtering for both conversion paths
  • add focused regression tests for both validation properties

Motivation

The HTTP/2 decoder already validates response header names, but Http2Handler rebuilt every response and trailer with new 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 DefaultHttpHeadersFactory configured to skip only name validation. Value validation remains enabled.

Validation

  • ./mvnw -pl client -Dtest=org.asynchttpclient.netty.handler.Http2HandlerTest test
    • 2 tests passed
  • selected HTTP/2 header, conformance, review, and residual regression suites
    • 60 tests passed

BasicHttp2Test#configRequestTimeoutHappensInDueTimeOverHttp2 was 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 verify gate was not run locally; the repository CI matrix provides JDK 11 coverage.

Attribution

Codex on behalf of Pavel Ptashyts

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>
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