He-Pin opened a new pull request, #1077: URL: https://github.com/apache/pekko-http/pull/1077
## 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](https://www.rfc-editor.org/rfc/rfc10008) 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](https://github.com/netty/netty/pull/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 - [x] `sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.HttpMethodsSpec"` → 6 passed - [x] `sbt "http-core / Test / testOnly org.apache.pekko.http.impl.model.parser.HttpHeaderSpec"` → 75 passed - [x] `sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.headers.HeaderSpec"` → 18 passed - [x] `sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.server.directives.MethodDirectivesSpec"` → 14 passed - [x] `sbt "docs / Test / testOnly docs.http.scaladsl.server.directives.MethodDirectivesExamplesSpec docs.http.javadsl.server.directives.MethodDirectivesExamplesTest"` → 11 passed - [x] `sbt "http-core / mimaReportBinaryIssues"` → success - [x] `sbt "http / mimaReportBinaryIssues"` → success - [x] `git diff --check` → clean - [x] scalafmt + javafmt applied ## References Refs https://github.com/netty/netty/pull/16978, https://www.rfc-editor.org/rfc/rfc10008 ### Tests - All directional tests pass (see test plan above) ### References Refs https://github.com/netty/netty/pull/16978, Refs https://www.rfc-editor.org/rfc/rfc10008 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
