Add support for the HTTP QUERY method (RFC 10008)#4140
Conversation
QUERY (RFC 10008, June 2026; registered in the IANA HTTP Method Registry) is safe and idempotent like GET but carries a request body like POST. It is wired through exactly like PATCH: - actix-web: `guard::Query()`, `web::query()`, `Resource::query()`, and `TestRequest::query()` - actix-web-codegen: `#[query]` routing macro (plus re-export from actix-web) `http` 0.2 has no `Method::QUERY` constant, so the method is built with `Method::from_bytes(b"QUERY").unwrap()`, with a TODO to switch to the constant once the `http` dependency is bumped (actix#3384). No dependency changes. `actix-http` needs no change (it uses `http::Method` directly). Tests mirror the existing PATCH coverage and add a body-carrying QUERY test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extend HTTP QUERY (RFC 10008) support to the remaining per-method convenience surfaces, mirroring PATCH: - awc: `Client::query()` - actix-test: `TestServer::query()` - actix-http-test: `TestServer::query()` and the HTTPS `TestServer::squery()` Also tighten `TestRequest::query()`'s doc to match its sibling helpers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Samielakkad
left a comment
There was a problem hiding this comment.
The core QUERY routing and awc::Client::query() paths have coverage, but the new test-server helpers look untested:
actix_test::TestServer::query()actix_http_test::TestServer::query()actix_http_test::TestServer::squery()
Those are small wrappers, but they are public convenience APIs and they can regress independently from web::query() / TestRequest::query() because they build full client requests from server URLs. It would be good to add a minimal test that starts a server with a web::query() route and reaches it through each new helper, at least for the non-TLS helpers if TLS coverage is awkward in this crate.
That would also prove the method survives the client/server round trip, not just the in-process service tests.
|
@Samielakkad added in fcbf37f, one per helper. |
Exercise each new helper against a live server: - actix_test::TestServer::query() through a web::query() route, request body included - actix_http_test::TestServer::query() over plaintext HTTP/1 - actix_http_test::TestServer::squery() over rustls, asserting the request arrives as QUERY over HTTP/2 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2a7a1b5 to
fcbf37f
Compare
PR Type
Feature
PR Checklist
Overview
Adds first-class support for the HTTP
QUERYmethod, wired exactly like the existingPATCHmethod throughout routing, guards, theweb::helpers, the routing macros, theawcclient, and the test servers.QUERYwas standardized in RFC 10008(June 2026) and registered in the IANA HTTP Method Registry. It is safe and
idempotent like
GET, but carries a request body likePOST— the first new HTTPmethod since
PATCH(RFC 5789, 2010). Because actix-web's extractors are method-agnostic,body extraction (
web::Json,web::Bytes, …) works forQUERYhandlers with no specialhandling.
This is a purely additive change (new public items only) → semver-minor; no breaking
changes.
What's included
actix-webguard::Query()— method guard, mirrorsguard::Patch()web::query()— pre-configuredRoute, mirrorsweb::patch()Resource::query()— route shortcut, mirrorsResource::patch()TestRequest::query()— test helper, mirrorsTestRequest::patch()#[query]routing macroactix-web-codegen#[query]attribute macro, mirrors#[patch]awcClient::query()— mirrorsClient::patch()actix-test/actix-http-testTestServer::query()(andactix-http-test's HTTPSTestServer::squery()) — mirrorpatch/spatchEvery method-convenience surface that has a
patchnow has a matchingquery, soQUERYis a first-class method throughout.
Notes for reviewers
httpcrate version. actix-web currently pinshttp0.2, which has noMethod::QUERYassociated constant (that constant only exists inhttp1.x). This PRtherefore constructs the method with
Method::from_bytes(b"QUERY").unwrap()and leaves aTODOto switch toMethod::QUERYonce the dependency is bumped. This mirrors theexisting
Method::from_bytes(...).unwrap()pattern already used inactix-web-codegenfor custom methods. This PR does not bump
http— that is tracked separately inUpdating to HTTP crate v1 #3384. No new dependencies are added.
actix-http. No change needed:actix-httpre-exportshttp::Methodand has nolocal method enum/constant list, so there is nothing to mirror there.
PATCHsite. Nounrelated refactoring.
Tests
guard::Query()matches aQUERYrequest and rejects aGET.web::query()route returns200forQUERYand405(Allow: QUERY) for other methods.QUERYhandler reads and echoes a JSON body (proves body-carrying works).#[query]macro integration test mirrors the existing#[patch]test (test_body).awc::Client::query()builds a request whose method isQUERY.actix_test::TestServer::query()(body echo through a
web::query()route),actix_http_test::TestServer::query()(plaintext HTTP/1),and
actix_http_test::TestServer::squery()(rustls; asserts the request arrives asQUERYover HTTP/2).Verification
Local, matching the project's CI gates:
cargo +nightly fmt --all -- --check— clean.cargo clippy --workspace --all-targets ... -D clippy::todo -D clippy::dbg_macro— 0 warnings.cargo +nightly doc --no-deps ... -D warnings— my[QUERY]intra-doc link resolves; no new warnings.just check-min/just check-default(cargo hack --workspace check [--no-default-features]) — pass.cargo +1.88(MSRV) check — pass.actix-web,actix-web-codegen,awc,actix-test,actix-http-test(incl. doctests and awc integration/TLS tests), 0 failed.