Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response body being null on 204/205/304 etc doesn't match any implementation #1779

Open
noamr opened this issue Oct 23, 2024 · 2 comments
Open

Comments

@noamr
Copy link
Contributor

noamr commented Oct 23, 2024

What is the issue with the Fetch Standard?

As per the standard, Response.body returns null if the body is null, https://fetch.spec.whatwg.org/#dom-body-body and https://fetch.spec.whatwg.org/#ref-for-null-body-status. However, no browser implements this. In all the implementations, a 204/205/304 response etc. would result in a Response.body of an empty stream.

Perhaps the fetch spec should be fixed to reflect implemented reality?

@annevk
Copy link
Member

annevk commented Oct 23, 2024

It's unfortunate to not reflect the actual HTTP semantics, but it's probably okay? We do return null in certain cases though (new Response().body), so it's a bit weird.

@noamr
Copy link
Contributor Author

noamr commented Oct 24, 2024

It's unfortunate to not reflect the actual HTTP semantics, but it's probably okay? We do return null in certain cases though (new Response().body), so it's a bit weird.

Yea thinking to spec it so that an http null body status would end up with an empty stream, but Response.body would still account for null like today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants