feat: support HTTP QUERY method (RFC 10008)#5459
Conversation
Add QUERY to normalized method records, safe HTTP methods, idempotent default, retryable methods, and fetch safe methods. Closes #5454
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5459 +/- ##
=======================================
Coverage 93.46% 93.47%
=======================================
Files 110 110
Lines 37106 37118 +12
=======================================
+ Hits 34682 34696 +14
+ Misses 2424 2422 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
One correctness note before this lands: adding I'm creating issues/PRs for improved retries and caching on my fork (GenAI-assisted), I am happy to upstream those issues/PRs once I have reviewed them. |
…memory) Make streaming QUERY request bodies cacheable/deduplicable instead of bypassing them. Both interceptors buffer a stream body up to a configurable cap (maxRequestBodyKeySize, default 1 MiB) to compute the body-aware key: - body <= cap: buffered, hashed, cached/deduplicated (no re-upload on hit) - body > cap: reconstructed (read prefix + piped remainder) and forwarded uncached, keeping peak memory at ~cap (no OOM on huge bodies) Adds readRequestBodyForKey/isStreamingRequestBody to lib/util/cache.js, the maxRequestBodyKeySize option + validation to both interceptors, and types. Deliberately omits request-body prefix-hash checkpoints and the forward-then-abort-before-last-chunk trick: hashing is cheap relative to the transfer; prefix-optimistic dedup is unsound (bodies can diverge after the prefix); and aborting after uploading ~all of an unbufferable body saves nothing. Avoiding the upload of a body too large to buffer requires a protocol-level request digest (RFC 9530), not a client-side trick. Refs: nodejs#5454, nodejs#5459 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Description
Adds support for the HTTP QUERY method standardized in RFC 10008 (June 2026), enabling safe/idempotent requests with bodies.
Changes
lib/core/util.js: AddedQUERYto normalized method records andsafeHTTPMethodslib/core/request.js: QUERY is idempotent by default (safe to retry)lib/handler/redirect-handler.js: Comment clarifying QUERY is safe (like GET) and won't change method on 301/302 redirectslib/handler/retry-handler.js: QUERY added to default retryable methodslib/web/fetch/constants.js: QUERY added tosafeMethodsfor the Fetch APICloses #5454