Uh oh!
There was an error while loading. Please reload this page.
feat: support HTTP QUERY method (RFC 10008) as payload method - #623
feat: support HTTP QUERY method (RFC 10008) as payload method#623wahajahmed010 wants to merge 1 commit into
Conversation
The HTTP QUERY method, recently standardized as a proposed standard in RFC 10008, is intended to carry a body payload for queries that are too large for a GET query string. Like POST/PUT/PATCH/DELETE, it should be treated as a payload method so that: - bodies are JSON-stringified automatically - default Content-Type/Accept headers are set - the default retry behavior matches other non-idempotent methods Without this, passing a JS object as the body of a QUERY request results in fetch() receiving '[object Object]' or a TypeError. Closesunjs#610
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds ChangesQUERY payload support
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk:⚪ Minimal · up to This localized change adds JSON body handling for HTTP QUERY requests and updates the associated documentation and regression coverage; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Summary
Treat the HTTP QUERY method (RFC 10008, recently accepted as a proposed standard) as a payload method, alongside PATCH/POST/PUT/DELETE. Without this change, passing a JS object as the body of a
QUERYrequest results in[object Object]being sent tofetch()(or aTypeError).Per #610, this PR is a one-line code change plus a regression test and a README update.
Changes
src/utils.ts: add"QUERY"to thepayloadMethodsset soisPayloadMethod()returns true for QUERY.README.md: update the lists of payload methods in the JSON Body and Retry sections to include QUERY (the current README was already inconsistent — the source includes DELETE while the README JSON Body section omits it).test/index.test.ts: add a regression test verifying that bodies on QUERY requests are JSON-stringified and the defaultContent-Type: application/jsonandAccept: application/jsonheaders are set.Why QUERY is a payload method
QUERY is the IETF standardized answer to "how do I send a body for a query when the GET query string is too long". Like POST/PUT/PATCH, it carries a request body, so the same default-handling applies:
Content-Type: application/jsonandAccept: application/jsonby default,Test plan
pnpm vitest run— 29/29 tests pass (28 existing + 1 new)pnpm lint— clean (eslint + prettier)Closes#610
Summary by CodeRabbit
New Features
QUERYrequests now support JSON object bodies.Content-TypeandAcceptheaders are set toapplication/jsonfor JSONQUERYrequests.QUERYrequests are included in the default retry exclusions.Documentation
QUERYrequests.