Skip to content

fetch() should throw TypeError: HEAD or GET Request cannot have a body #2014

@ISO50

Description

@ISO50

What version of Bun is running?

0.5.5

What platform is your computer?

Darwin 22.2.0 arm64 arm

What steps can reproduce the bug?

fetch("https://url", { 
  body: 'content ....' 
})

What is the expected behavior?

Should throw a TypeError with some message like: HEAD or GET Request cannot have a body.

I am not sure if this is specified in the whatwg standard, but this behavior seems to be standard across browser implementations and nodejs, see also: https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions

What do you see instead?

Instead it seems like a GET or OPTIONS request is executed.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingweb-apiSomething that relates to a standard Web API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions