Repository navigation
feat: parse the body of QUERY requests by default - #86
Open
DavideCarvalho wants to merge 1 commit into
Open
DavideCarvalho wants to merge 1 commit into
DavideCarvalho wants to merge 1 commit into
Conversation
The QUERY HTTP method (RFC 10008) carries the query in the request content, so request.body() must be populated for it just like POST. Add QUERY to the default allowedMethods list. Refs adonisjs/http-server#140 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
QUERYto the defaultallowedMethodslist returned bydefineConfig, sorequest.body()is populated forQUERYrequests the same way it is forPOST,PUT,PATCHandDELETE.Companion to adonisjs/http-server#140, which adds
router.query().Why
QUERY(RFC 10008) is a safe, idempotent method whose query is carried in the request content rather than the URL. Without this change the bodyparser skipsQUERYrequests and the route handler always sees an empty body.Unsupported content types keep the current behavior (
bodyType: 'unknown', raw stream left untouched), so routes can still handle custom query formats such asapplication/sqlthemselves.Existing apps
Explicitly configured
allowedMethodslists are not touched, and the starter kits set the list explicitly inconfig/bodyparser.ts, so existing and newly created apps need'QUERY'added there to opt in:adonisjs/starter-kits:api,api-monorepo/apps/backend,hypermedia,inertia-react,inertia-vue(config/bodyparser.ts)adonisjs/v7-docs:content/guides/basics/body_parser.mdandcontent/reference/config/bodyparser.md(covered in the docs PR forrouter.query())Happy to send PRs for the starter kits too if you want them updated.
Tests
defineConfig({})includesQUERYinallowedMethodsQUERYrequest populatesrequest.body()withbodyType: 'json'QUERYrequest populatesrequest.body()withbodyType: 'urlencoded'QUERYrequests are skipped whenallowedMethodsis set explicitly without itSupertest has no typed API for
QUERY, so these tests send real requests withundici'sfetch.npm test(lint + 206 tests),npm run typecheckand the build (tsdown+tsc --emitDeclarationOnly) all pass.🤖 Generated with Claude Code