Skip to content

Implement the HTTP QUERY method (RFC 10008)#261

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

Implement the HTTP QUERY method (RFC 10008)#261
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): a safe, idempotent HTTP method that carries the query as request content, for queries too large or too sensitive to encode in the URL.

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). Full unit suite green locally except 3 pre-existing ModeTest errors (missing Utopia\System\System in the local env, fails on a clean checkout too).

Related PRs and Issues

None.

Adds first-class support for the QUERY method: 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

Thanks for contributing! This repository is a read-only mirror — development for this library happens in packages/http in the utopia-php monorepo. Please open this pull request there instead.

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