Skip to content

Add RFC 10008 QUERY Method support (#16966) - #16978

Merged
chrisvest merged 1 commit into
4.1from
m41
Jun 19, 2026
Merged

chrisvest merged 1 commit into
4.1from
m41

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

Add basic blocks for RFC 10008 (The HTTP QUERY method)

Modification:

Added the QUERY HttpMethod as well as the Accept-Query header constant

Result:

Downstream consumers have an easier time implementing RFC 10008

Motivation:

Add basic blocks for RFC 10008 (The HTTP QUERY method)

Modification:

Added the QUERY HttpMethod as well as the Accept-Query header constant

Result:

Downstream consumers have an easier time implementing RFC 10008
@chrisvest chrisvest added this to the 4.1.136.Final milestone Jun 19, 2026
@chrisvest
chrisvest merged commit ec224a0 into 4.1 Jun 19, 2026
19 checks passed
@chrisvest
chrisvest deleted the m41 branch June 19, 2026 00:58
@He-Pin

He-Pin commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

So this only lives in Http/1.1?

He-Pin added a commit to apache/pekko-http that referenced this pull request Jul 1, 2026
* feat: add RFC 10008 QUERY method and Accept-Query header support

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

* test: add RFC 10008 QUERY method property tests and clean up imports

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

* Align Accept-Query with RFC 10008

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

* fix: use standard ASF license header for AcceptQuery.java

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

* refactor: replace private[this] with private in parser and headers

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
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
Motivation:

Add basic blocks for RFC 10008 (The HTTP QUERY method)

Modification:

Added the QUERY HttpMethod as well as the Accept-Query header constant

Result:

Downstream consumers have an easier time implementing RFC 10008

Co-authored-by: Mario Daniel Ruiz Saavedra <[email protected]>
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.

4 participants