Add HTTP QUERY method support (RFC 10008) by ewalsh · Pull Request #14072 · playframework/playframework · GitHub
Skip to content

Add HTTP QUERY method support (RFC 10008) - #14072

Open
ewalsh wants to merge 4 commits into
playframework:mainfrom
ewalsh:feature/http-query-method-rfc10008
Open

ewalsh wants to merge 4 commits into
playframework:mainfrom
ewalsh:feature/http-query-method-rfc10008

Conversation

@ewalsh

@ewalsh ewalsh commented Jul 7, 2026 •

Copy link
Copy Markdown

Pull Request Checklist

Fixes

N/A (new feature)

Purpose

Add first-class support for the HTTP QUERY method as defined in RFC 10008.

The QUERY method is a safe, idempotent request method that carries a request body — combining the safety semantics of GET with the body-carrying capability of POST. It was published as a Proposed Standard in 2025 and addresses the long-standing need for content-bearing safe requests (e.g., complex search queries that exceed URL length limits).

Background Context

RFC 10008 defines QUERY as:

  • Safe — does not alter server state (like GET)
  • Idempotent — multiple identical requests have the same effect
  • Cacheable — responses can be cached (keyed by request body via Content-Location)
  • Body-bearing — the request content defines the query

This makes QUERY exempt from CSRF checks (same as GET/HEAD/OPTIONS) and suitable for the routes compiler, SIRD router, and all existing HTTP method infrastructure.

Changes

Core Constants

  • Added QUERY to HttpVerbs trait (Scala) and HttpVerbs interface (Java)
  • Added ACCEPT_QUERY to HeaderNames trait (Scala) and HeaderNames interface (Java)

Routes Compiler

  • Added "QUERY" to the httpVerb parser alternatives in RoutesFileParser.scala

SIRD Router

  • Added QUERY extractor to RequestMethodExtractors trait

Java Routing DSL

  • Added QUERY(String pathPattern) convenience method to RoutingDsl

CSRF Filter

  • Added "QUERY" to CSRFConfig.SafeMethods set (code default)
  • Added "QUERY" to reference.conf method whitelist

Pekko HTTP Server

  • Registered QUERY as a custom method via ParserSettings.withCustomMethods so Pekko HTTP accepts the method without returning 501

Binary Compatibility

  • Added MiMa exclusion filters for the new trait members (ReversedMissingMethodProblem)

Documentation

  • Updated HTTP method lists in ScalaRouting.md, JavaRouting.md
  • Updated SIRD extractor docs in ScalaSirdRouter.md
  • Updated Java Routing DSL docs in JavaRoutingDsl.md
  • Updated CSRF safe method docs in ScalaCsrf.md, JavaCsrf.md

Tests

  • Routes compiler parser test
  • SIRD router test (RouterSpec)
  • CSRF filter test (CSRFFilterSpec)
  • Java Routing DSL test (AbstractRoutingDslTest)
  • Scripted integration test (routes-compiler-routes-compilation-java)

Upstream Dependencies

Play WS (merged)

Play WS standalone has an open PR for QUERY method support in playframework/play-ws#1366. This adds query[T: BodyWritable](body: T) to the Scala API and query(BodyWritable body) to the Java API. No upstream AHC changes were required — execute("QUERY") preserves the request body for custom method strings.

Pekko HTTP (merged, not yet released)

Apache Pekko HTTP has merged built-in QUERY method support in apache/pekko-http#1077, adding HttpMethods.QUERY as a recognized constant. This landed on main after v2.0.0-M1 and is not yet in a published artifact. Once released, the withCustomMethods workaround in PekkoHttpServer.scala can be removed in favor of the built-in constant.

References

Implement first-class support for the HTTP QUERY method across the
framework: core constants, routes compiler, SIRD router, Java Routing
DSL, CSRF filter safe methods, and Pekko HTTP custom method registration.

QUERY is safe, idempotent, and body-bearing — combining GET's safety
semantics with POST's ability to carry request content.

Ref: https://www.rfc-editor.org/rfc/rfc10008
@He-Pin

He-Pin commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@ewalsh

ewalsh commented Jul 10, 2026

Copy link
Copy Markdown
Author

there is a snpashot which you can use for pekko

Yes, thank you for the pointer! I will track and update when stable release is ready.

@mkurz

mkurz commented Jul 10, 2026

Copy link
Copy Markdown
Member

Yes, thank you for the pointer! I will track and update when stable release is ready.

I didnt review this pull request, but current Play main branch already uses pekko http snapshot, so you can make use of its query implemention already

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.
@ewalsh

ewalsh commented Jul 12, 2026

Copy link
Copy Markdown
Author

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