Skip to content

feat: support HTTP QUERY method (RFC 10008) as payload method - #623

Open
wahajahmed010 wants to merge 1 commit into
unjs:mainfrom
wahajahmed010:fix/610-http-query-method
Open

feat: support HTTP QUERY method (RFC 10008) as payload method#623
wahajahmed010 wants to merge 1 commit into
unjs:mainfrom
wahajahmed010:fix/610-http-query-method

Conversation

@wahajahmed010

@wahajahmed010wahajahmed010 commented Aug 16, 2026

Copy link
Copy Markdown

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 QUERY request results in [object Object] being sent to fetch() (or a TypeError).

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 the payloadMethods set so isPayloadMethod() 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 default Content-Type: application/json and Accept: application/json headers 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:

  • auto-stringify JS objects to JSON,
  • set Content-Type: application/json and Accept: application/json by default,
  • disable the default retry (QUERY is not declared safe / idempotent in RFC 10008).

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

    • QUERY requests now support JSON object bodies.
    • Object bodies are automatically serialized as JSON.
    • Default Content-Type and Accept headers are set to application/json for JSON QUERY requests.
    • QUERY requests are included in the default retry exclusions.
  • Documentation

    • Updated documentation to describe JSON-header behavior and retry exclusions for QUERY requests.

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
@coderabbitai

coderabbitaiBot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 163c1654-1820-49be-b605-5c11c7db26ba

📥 Commits

Reviewing files that changed from the base of the PR and between 1dbc37f and f8441f2.

📒 Files selected for processing (3)
  • README.md
  • src/utils.ts
  • test/index.test.ts

Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The change adds QUERY to payload methods. QUERY object bodies now receive JSON serialization and default JSON headers. The README documents JSON headers and retry exclusions for QUERY.

Changes

QUERY payload support

Layer / File(s)Summary
QUERY payload behavior and documentation
src/utils.ts, test/index.test.ts, README.md
QUERY is recognized as a payload method. Tests verify JSON body serialization and default JSON headers. The README documents JSON headers and default retry exclusions for QUERY.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk:⚪ Minimal · up to f8441

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)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly describes adding HTTP QUERY support as a payload method.
Linked Issues check✅ PassedThe changes add QUERY to payloadMethods, update related documentation, and test JSON body handling required by issue #610.
Out of Scope Changes check✅ PassedAll changes directly support HTTP QUERY payload handling, documentation, or regression testing.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for freeto 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.

Add support for RFC 10008 - HTTP QUERY

1 participant

@wahajahmed010