Skip to content

fix: recognize QUERY in the HTTP/1 request parser - #1477

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/http1-query-method
Nov 17, 2026
Merged

He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/http1-query-method

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 16, 2026

Copy link
Copy Markdown
Member

Motivation:
Pekko already models QUERY, but the HTTP/1 parser sends it to the custom method lookup. Without a custom method registration, an ordinary QUERY request is rejected before it reaches the route.

Modification:
Recognize QUERY in the built-in method dispatch. Add a parser regression test with a typed, fixed-length request body and no custom method registration.

Result:
HTTP/1 recognizes the standard QUERY method and parses its body. A same-name custom registration no longer takes precedence, consistent with other built-in methods. Other method names still use the existing custom fallback.

References:
#1077
https://www.rfc-editor.org/rfc/rfc10008.html#section-2 netty/netty#16966

Motivation:
Pekko already models QUERY, but the HTTP/1 parser sends it to the
custom method lookup. Without a custom method registration, an
ordinary QUERY request is rejected before it reaches the route.

Modification:
Recognize QUERY in the built-in method dispatch. Add a parser
regression test with a typed, fixed-length request body and no custom
method registration.

Result:
HTTP/1 recognizes the standard QUERY method and parses its body.
A same-name custom registration no longer takes precedence, consistent
with other built-in methods. Other method names still use the
existing custom fallback.

References:
apache#1077
https://www.rfc-editor.org/rfc/rfc10008.html#section-2
netty/netty#16966
@pjfanning pjfanning added this to the 2.1.0 milestone Nov 16, 2026

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good. QUERY is already modeled, and adding it to the first-byte dispatch puts it on the same fast path as the other built-in methods. parseMethod falls back to parseCustomMethod() on any mismatch, so other methods starting with Q still reach the custom lookup.

Minor: since this adds the first 'Q' branch, a test with a registered custom method that starts with Q but isn't QUERY (e.g. QUOTE) would pin that fallback, so a later change to the dispatch can't swallow it. Not blocking.

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin
He-Pin merged commit 2d416dc into apache:main Nov 17, 2026
6 checks passed
@He-Pin
He-Pin deleted the fix/http1-query-method branch November 17, 2026 15:04
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 QUERY method is registered in the HTTP model and tested by the
HTTP/1 parser, but has no focused HTTP/2 request parser test.

Modification:
Parse one ordinary QUERY request through the existing in-memory
HTTP/2 fixture with default settings and assert the typed method.

Result:
The HTTP/2 request-parser test covers the built-in QUERY method
without changing production behavior.

References:
#1077
#1477
https://www.rfc-editor.org/rfc/rfc9113.html#section-8.3.1
https://www.rfc-editor.org/rfc/rfc10008.html#section-2
He-Pin added a commit that referenced this pull request Nov 28, 2026
Motivation:
HTTP method names are case-sensitive. The existing custom method
example covers a single uppercase name but not two case variants.

Modification:
Register two distinct custom methods and send modeled requests over
one HTTP/1.1 loopback connection. Drain the entities and verify the
exact method names observed by the server against the original names.

Result:
The test covers the client renderer and server parser together.
No production behavior or defaults change.

Tests:
- Stock http-core Test ClientServerSpec focused case: 1 passed on
  Scala 2.13.18 and 1 passed on Scala 3.3.9 using Temurin 17.
- http-core / Test / scalafmtCheck and git diff --check passed.

References:
RFC 9110, section 9.1. Refs #1477 (adjacent QUERY parser coverage).
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.

3 participants