Skip to content

Response constructor accepts body for status 205 instead of throwing #5207

@HiteshShonak

Description

@HiteshShonak

Describe the bug
new Response() silently accepts a body when the status is 205. the Fetch Standard defines 205 as a null body status, so passing a body should throw a TypeError - same as 204 and 304 which already throw correctly in Boa.

To Reproduce

new Response("x", { status: 205 })
// no error in Boa, expected TypeError

Verified in Node.js:

node -e 'try { new Response("x", { status: 205 }); console.log("OK"); } catch (e) { console.log(e.name + ": " + e.message); }'
# TypeError: Response constructor: Invalid response status code 205

cargo run --bin boa -- -e 'try { new Response("x", { status: 205 }); console.log("OK"); } catch (e) { console.log(e.name + ": " + e.message); }'
# OK

Expected behavior
new Response("x", { status: 205 }) should throw a TypeError, matching Node.js and browser behavior. new Response(null, { status: 205 }) should still be fine.

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/response.rs - 205 is missing from the is_null_body_status check.

Spec reference: https://fetch.spec.whatwg.org/#null-body-status

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions