feat: add QUERY method (core support)#1445
Conversation
📝 WalkthroughWalkthroughThis PR adds first-class support for the HTTP "QUERY" method: extending the ChangesQUERY Method Support
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
pi0x
left a comment
There was a problem hiding this comment.
Approving — this is a clean, well-tested implementation of the core QUERY method support slice of #1441.
Covered ✅
"QUERY"added to theHTTPMethodunion and theH3class type declarationapp.query()shortcut (runtime method loop) andapp.on("QUERY", …)both work;defineRouteinherits QUERY for free viaHTTPMethodreadBody/readValidatedBodyon QUERY bodies (body reading isn't method-gated) — covered by testsassertBodySize/ body limits — covered- Proxy forwards QUERY request bodies (
QUERYadded toPayloadMethods) — covered - Bundle-size budget bumped accordingly
All new tests pass locally (router, body, proxy, body-limit).
Follow-ups still needed to fully close #1441
This PR intentionally lands only the first sequenced slice. Remaining items from the issue for future PRs:
setAcceptQuery()/getAcceptQuery()header utilities (Structured Fields List)- Optional Content-Type validation helper (400 missing / 415 unsupported / 422 unprocessable)
- CORS preflight audit + test for QUERY (non-safelisted → always preflighted; note that an explicit
methodsallowlist must include"QUERY") - Cache-header audit + test (
If-None-Match/If-Modified-Since/ 304)
Suggest keeping #1441 open with a checklist for the above.
Disclaimer: this review was generated with AI assistance (Claude Code) and reviewed before posting.
Follow-up to QUERY method support (#1445) for RFC 10008. - `setResponseAcceptQuery` / `getResponseAcceptQuery`: advertise and read the supported query media types via the `Accept-Query` response header, serialized as a Structured Fields (RFC 8941) List. - `requireContentType`: opt-in request `Content-Type` validation throwing `400` (missing), `422` (malformed), or `415` (unsupported), with wildcard support (`*/*`, `type/*`). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Follow-up to QUERY method support (#1445) for RFC 10008. - `setResponseAcceptQuery`: advertise the supported query media types via the `Accept-Query` response header, serialized as a Structured Fields (RFC 8941) List. - `requireContentType`: opt-in request `Content-Type` validation throwing `400` (missing), `422` (malformed), or `415` (unsupported), with wildcard support (`*/*`, `type/*`). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Follow-up to QUERY method support (#1445) for RFC 10008. - `setAcceptQuery`: advertise the supported query media types via the `Accept-Query` response header, serialized as a Structured Fields (RFC 8941) List. - `requireContentType`: opt-in request `Content-Type` validation throwing `400` (missing), `422` (malformed), or `415` (unsupported), with wildcard support (`*/*`, `type/*`). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Summary
Adds first-class support for the HTTP
QUERYmethod from RFC 10008. #1441.Changes
QUERYto theHTTPMethodtypeapp.query(route, handler, opts)alongside the existing method helpersQUERYrequest bodies when usingproxyRequest()Non-goals
This keeps the first PR small and does not add
Accept-Queryutilities or opt-in content-type validation helpers. Those can be follow-up PRs if wanted.Tests
corepack pnpm vitest run test/router.test.ts test/body.test.ts test/proxy.test.ts test/unit/body-limit.test.tscorepack pnpm lintcorepack pnpm vitest run test/router.test.ts test/body.test.ts test/proxy.test.ts test/unit/body-limit.test.ts test/bench/bundle.test.tscorepack pnpm testSummary by CodeRabbit
New Features
QUERYrequest method, including a matching route handler helper.Tests
QUERYrequests.