Skip to content

Request constructor accepts body for GET and HEAD methods instead of throwing #5200

Description

@HiteshShonak

Describe the bug
new Request() silently accepts a body when the method is GET or HEAD, but the Fetch Standard requires throwing a TypeError in this case. Boa just proceeds without any error.

To Reproduce

new Request("https://example.com", { method: "GET", body: "x" })
// no error in Boa, expected TypeError

new Request("https://example.com", { method: "HEAD", body: "x" })
// no error in Boa, expected TypeError

Verified in Node.js:

node -e 'try { new Request("https://example.com", { method: "GET", body: "x" }); console.log("OK"); } catch (e) { console.log(e.name + ": " + e.message); }'
# TypeError: Request with GET/HEAD method cannot have body.

Expected behavior
new Request() should throw a TypeError when body is provided with GET or HEAD, matching Node.js and browser behavior.

Build environment:

  • OS: Windows 11
  • Version: 10.0.26200
  • Target triple: x86_64-pc-windows-msvc
  • Rustc version: rustc 1.94.0 (4a4ef493e 2026-03-02)

Additional context
Root cause is in core/runtime/src/fetch/request.rs where into_request_builder sets method and body separately without checking the GET/HEAD + body restriction.

Spec reference: https://fetch.spec.whatwg.org/#dom-request

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions