GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add RFC 10008 QUERY method and Accept-Query header support by He-Pin · Pull Request #1077 · apache/pekko-http

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary

  • Add QUERY HTTP method constant (safe, idempotent, expects request body per RFC 10008) to both Scala and Java API
  • Add Accept-Query modeled response header with enhanced parser supporting RFC 9651 Structured Fields syntax (quoted strings, q-value stripping)
  • Add query routing directive for both Scala DSL and Java DSL
  • Add HttpRequest.QUERY() factory method for Java API
  • Add documentation page and directional tests

Motivation

RFC 10008 defines the HTTP QUERY method as a safe and idempotent method that expects a request body, along with the Accept-Query response header. pekko-http should provide first-class support for this standard HTTP method, similar to what Netty did in PR #16978.

Modification

Core (http-core)

  • HttpMethod.scala: Add QUERY to HttpMethods (safe=true, idempotent=true, requestEntityAcceptance=Expected)
  • HttpMethods.java: Add QUERY constant to Java API
  • HttpRequest.java: Add QUERY(String uri) factory method
  • headers.scala: Add Accept-Query modeled response header (Seq[MediaRange])
  • AcceptQuery.java: New Java API abstract class
  • HeaderParser.scala: Register accept-query in dispatch
  • AcceptHeader.scala: Add accept-query parser with RFC 9651 Structured Fields support:
    • Handles both token (application/json) and quoted-string ("application/jsonpath") forms
    • Strips q-values (not meaningful for Accept-Query per RFC 10008)

Routing (http)

  • MethodDirectives.scala (scaladsl): Add query directive
  • MethodDirectives.scala (javadsl): Add query directive

Documentation (docs)

  • New query.md page for the query method directive
  • Scala and Java examples in doc tests

Tests

  • HttpMethodsSpec: QUERY method lookup
  • HttpHeaderSpec: Accept-Query parsing (token, quoted string, wildcard, q-value stripping, RFC example)
  • HeaderSpec: Accept-Query rendering
  • MethodDirectivesSpec: query directive routing
  • MethodDirectivesExamplesSpec / MethodDirectivesExamplesTest: doc examples

Result

Downstream consumers can implement RFC 10008 QUERY method support using built-in constants, headers, parsing, and routing directives.

Test plan

  • sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.HttpMethodsSpec" → 6 passed
  • sbt "http-core / Test / testOnly org.apache.pekko.http.impl.model.parser.HttpHeaderSpec" → 75 passed
  • sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.headers.HeaderSpec" → 18 passed
  • sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.server.directives.MethodDirectivesSpec" → 14 passed
  • sbt "docs / Test / testOnly docs.http.scaladsl.server.directives.MethodDirectivesExamplesSpec docs.http.javadsl.server.directives.MethodDirectivesExamplesTest" → 11 passed
  • sbt "http-core / mimaReportBinaryIssues" → success
  • sbt "http / mimaReportBinaryIssues" → success
  • git diff --check → clean
  • scalafmt + javafmt applied

References

Refs netty/netty#16978, https://www.rfc-editor.org/rfc/rfc10008

Tests

  • All directional tests pass (see test plan above)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

desiderantes and hanishi reacted with heart emoji
All reactions
  • ❤️ 2 reactions
@He-Pin
feat: add RFC 10008 QUERY method and Accept-Query header support
6df05df
Motivation:
RFC 10008 defines the HTTP QUERY method as a safe, idempotent method that
expects a request body, along with the Accept-Query response header for
signaling supported query media types. pekko-http should provide first-class
support for this standard HTTP method.

Modification:
- Add QUERY method constant to HttpMethods (Scala and Java API)
- Add Accept-Query modeled response header with MediaRange list
- Add Accept-Query parser supporting RFC 9651 Structured Fields syntax
  (quoted strings like "application/jsonpath") with q-value stripping
- Add query routing directive (Scala DSL and Java DSL)
- Add HttpRequest.QUERY factory method (Java API)
- Add AcceptQuery Java API abstract class
- Register accept-query in HeaderParser dispatch
- Add documentation page for query directive with Scala/Java examples
- Add directional tests: method lookup, header parsing (token, quoted
  string, wildcard, q-value stripping), directive routing

Result:
Downstream consumers can implement RFC 10008 QUERY method support using
built-in constants, headers, parsing, and routing directives.

Tests:
- sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.HttpMethodsSpec" → 6 passed
- sbt "http-core / Test / testOnly org.apache.pekko.http.impl.model.parser.HttpHeaderSpec" → 75 passed
- sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.headers.HeaderSpec" → 18 passed
- sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.server.directives.MethodDirectivesSpec" → 14 passed
- sbt "docs / Test / testOnly docs.http.scaladsl.server.directives.MethodDirectivesExamplesSpec docs.http.javadsl.server.directives.MethodDirectivesExamplesTest" → 11 passed
- sbt "http-core / mimaReportBinaryIssues" → success
- sbt "http / mimaReportBinaryIssues" → success

References:
Refs netty/netty#16978, https://www.rfc-editor.org/rfc/rfc10008
@He-Pin He-Pin added the enhancement New feature or request label Jun 19, 2026
@He-Pin He-Pin added this to the 2.0.0-M2 milestone Jun 19, 2026
@He-Pin
test: add RFC 10008 QUERY method property tests and clean up imports
51c77fc
Motivation:
Review feedback identified missing directional tests for QUERY method
semantics (safe, idempotent, expected entity) and an unused import.

Modification:
- Add property tests verifying QUERY is safe, idempotent, and expects
  a request entity per RFC 10008 (goes beyond Netty's test coverage)
- Remove unused HttpMethod import from MethodDirectivesSpec

Result:
Stronger test coverage ensuring RFC 10008 semantics are preserved.

Tests:
- sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.HttpMethodsSpec" → 9 passed
- sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.server.directives.MethodDirectivesSpec" → 14 passed

References:
Refs https://www.rfc-editor.org/rfc/rfc10008
@He-Pin
He-Pin requested a review from pjfanning June 19, 2026 05:11
@He-Pin
Align Accept-Query with RFC 10008
98f8f94
Motivation:
Accept-Query is a Structured Field in RFC 10008, but the PR reused Accept media-range parsing and rendering in places that could emit invalid field values or treat parameters as Accept weights.

Modification:
Parse Accept-Query media ranges and parameters with Structured Field token/string rules. Render Accept-Query values with token-or-string selection, preserve valid SF parameters, reject invalid wildcard and decimal-parameter forms, and add focused parser/rendering tests. Add the query directive to the alphabetical docs index and fix Accept-Query RFC section links.

Result:
Accept-Query parsing and rendering now matches RFC 10008 Section 3 while keeping the parser path lightweight.

Tests:
- scalafmt --mode diff-ref=origin/main
- scalafmt --list --mode diff-ref=origin/main
- git diff --check
- sbt 'project http-core' 'Test / testOnly org.apache.pekko.http.impl.model.parser.HttpHeaderSpec'
- sbt 'project http-core' 'Test / testOnly org.apache.pekko.http.scaladsl.model.headers.HeaderSpec'
- sbt 'project http-core' 'Test / testOnly org.apache.pekko.http.scaladsl.model.HttpMethodsSpec'
- sbt 'http-tests / Test / testOnly org.apache.pekko.http.scaladsl.server.directives.MethodDirectivesSpec'
- sbt docs/paradox

References:
Refs #1077
@He-Pin
He-Pin requested a review from jrudolph June 19, 2026 08:21
pjfanning
pjfanning reviewed Jun 19, 2026
View reviewed changes
Comment thread http-core/src/main/java/org/apache/pekko/http/javadsl/model/headers/AcceptQuery.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@He-Pin
fix: use standard ASF license header for AcceptQuery.java
e6f426d
Motivation:
AcceptQuery.java is a new file with original code, not derived from
Akka. It should use the standard ASF license header, not the
"derived from Akka" header.

Modification:
Replace apacheFromAkkaSourceHeader with the standard apacheHeader as
defined in CopyrightHeader.scala.

Result:
AcceptQuery.java carries the correct license header for new
contributions.

References:
Refs #1077
He-Pin
He-Pin commented Jun 19, 2026
View reviewed changes

@He-Pin He-Pin left a comment

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed: AcceptQuery.java now uses the standard ASF license header (apacheHeader) instead of the Akka-derived header (apacheFromAkkaSourceHeader), as this is a new file with original code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@He-Pin
He-Pin requested a review from pjfanning June 19, 2026 08:39
@He-Pin
refactor: replace private[this] with private in parser and headers
ebd9990
Motivation:
`private[this]` is being phased out in Scala 3 and provides no
measurable benefit for vals in objects/traits.

Modification:
Replace `private[this]` with `private` in AcceptHeader.scala (3 vals)
and headers.scala (1 val).

Result:
Cleaner code compatible with Scala 3 conventions. scalafmt applied.

Tests:
Not run - visibility-only change

References:
Refs #1077
@pjfanning
pjfanning requested a review from raboof June 21, 2026 16:00
@He-Pin He-Pin mentioned this pull request Jun 25, 2026
Support QUERY http method playframework/playframework#14039
Open
pjfanning
pjfanning approved these changes Jun 30, 2026
View reviewed changes

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@He-Pin
He-Pin merged commit 4ac4b73 into main Jul 1, 2026
5 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ewalsh ewalsh mentioned this pull request Jul 7, 2026
Add HTTP QUERY method support (RFC 10008) playframework/playframework#14072
Open
7 tasks done
ewalsh added a commit to ewalsh/playframework that referenced this pull request Jul 12, 2026
@ewalsh
Use built-in HttpMethods.QUERY from Pekko HTTP snapshot
75cb9a6
Replace HttpMethod.custom("QUERY") with the built-in HttpMethods.QUERY
constant available in Pekko HTTP 2.0.0-M1+169-56f2f5ad-SNAPSHOT
(apache/pekko-http#1077). The withCustomMethods parser registration is
still required as the parser trie only covers the original 9 methods.
@He-Pin He-Pin mentioned this pull request Nov 16, 2026
fix: recognize QUERY in the HTTP/1 request parser #1477
Merged
He-Pin added a commit that referenced this pull request Nov 17, 2026
@He-Pin
fix: recognize QUERY in the HTTP/1 request parser (#1477)
2d416dc
Motivation:
The modeled QUERY method should not require custom parser registration.

Modification:
Add QUERY to built-in method dispatch and cover a typed fixed-length request body.

Result:
HTTP/1 recognizes QUERY consistently with other built-in methods.

Validation:
The owner reports CI passed for this PR. No additional CI inspection or local test run was performed during merge.

References:
#1077
He-Pin added a commit that referenced this pull request Nov 28, 2026
@He-Pin
test: verify HTTP/2 parses the standard QUERY method (#1781)
771632d
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pjfanning pjfanning pjfanning approved these changes
@jrudolph jrudolph Awaiting requested review from jrudolph
@raboof raboof Awaiting requested review from raboof

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

2.0.0-M2

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@He-Pin @pjfanning
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.