Skip to content

Implement the HTTP QUERY method (RFC 10008) in packages/http#42

Draft
ChiragAgg5k wants to merge 1 commit into
mainfrom
feat/http-query-method
Draft

Implement the HTTP QUERY method (RFC 10008) in packages/http#42
ChiragAgg5k wants to merge 1 commit into
mainfrom
feat/http-query-method

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What does this PR do?

Implements RFC 10008 — The HTTP QUERY Method (Standards Track, June 2026) in packages/http: a safe, idempotent HTTP method that carries the query as request content, for queries too large or too sensitive to encode in the URL.

Replaces utopia-php/http#261, which was closed in favor of a monorepo PR.

Changes

  • Routing: Http::REQUEST_METHOD_QUERY / Request::METHOD_QUERY constants, a QUERY bucket in Router (including reset()), and a Http::query('/path') shortcut alongside get()/post()/etc. Composes with Http::routes([...]) for multi-method routes.
  • Request content: QUERY joins the body-carrying methods in generateInput() for the FPM and Swoole adapters (SwooleCoroutine inherits), so a JSON QUERY body maps to route params exactly like POST.
  • RFC MUST enforcement (§2): a QUERY request without a Content-Type header is rejected with a 400 through the normal error-hook pipeline before the route action runs.
  • Discovery header (§3): Response::setAcceptQuery([...]) emits the Accept-Query field serialized as an RFC 9651 structured-field list of strings.
  • Docs: new "The QUERY Method" README section with a usage example.

Example

Http::query('/documents/search')
    ->param('filter', '', new Text(2048), 'Filter expression')
    ->inject('response')
    ->action(function(string $filter, Response $response) {
        $response->json(['results' => []]);
    });
QUERY /documents/search HTTP/1.1
Content-Type: application/json

{"filter": "status = 'active'"}

Out of scope

The RFC's caching rules (cache keys incorporating request content, normalization) and conditional-request semantics apply to caches; this library has no cache layer, so there is nothing to implement there.

Notes

  • Serving QUERY requires the underlying server to accept the method: PHP-FPM passes any method through, while Swoole support depends on the Swoole version's HTTP parser recognizing QUERY. Worth verifying in the e2e/docker setup.

Test Plan

7 new tests: HttpTest (dispatch + 400 on missing Content-Type), RouterTest (QUERY matching isolated from GET), RequestTest (params come from the payload for QUERY), ResponseTest (Accept-Query serialization). Locally, the unit suite and phpstan show only pre-existing failures (missing Utopia\System class in Mode.php/ModeTest), identical on a clean checkout.

Related PRs and Issues

Adds first-class support for the QUERY method in packages/http: routing
via Http::query() and Router buckets, request body parsing in the FPM and
Swoole adapters, the RFC-mandated 400 on missing Content-Type, and a
Response::setAcceptQuery() helper emitting the Accept-Query structured
field (RFC 9651).
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Benchmark results

http — Swoole modes (4 cores, 200 VUs, 20s/run)

workload mode req/s p95
ok a 13932.954694/s 30.95ms
ok b 15208.134681/s 28.49ms
io a 467.776989/s 553.54ms
io b 3345.86371/s 51.53ms
cpu a 3287.754133/s 166.97ms
cpu b 3082.663219/s 83.64ms

a = HYPERLOOP_A (process), b = HYPERLOOP_B (coroutine)

Shared CI runners — treat absolute numbers as rough, compare modes within a run. Commit b534a86.

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.

1 participant