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

HTTP responses for status codes that should have no body #25953

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bsmth
Copy link
Member

@bsmth bsmth commented Feb 18, 2025

Summary

HTTP responses with 204, 304, (1XX) should not contain content (a body). For historical / legacy reasons, browsers have tolerated junk data in <=HTTP/1.1 that precedes the status line because servers occasionally included content in responses that should not have a body. HTTP spec versions after 1.1 are strict / explicit in forbidding content in these cases.

I'm removing compat info from prose in MDN docs, and putting this into compat data instead, as this seems the most appropriate place for this to live on.

204 (No Content) is the most obvious place, but I'm open to alternatives somewhere (outside of http/status.json?)

Related issues

@github-actions github-actions bot added data:http Compat data for HTTP features. https://developer.mozilla.org/docs/Web/HTTP size:m [PR only] 25-100 LoC changed labels Feb 18, 2025
@caugner
Copy link
Contributor

caugner commented Feb 18, 2025

I'm not sure we should document this in BCD, as the spec doesn't seem to specify any browser behavior, even if the HTTP 204 response contains content.

Couldn't we keep a more concise warning about browsers potentially rejecting the data in content instead?

@bsmth
Copy link
Member Author

bsmth commented Feb 19, 2025

Couldn't we keep a more concise warning about browsers potentially rejecting the data in content instead?

I'm not opposed to this, it's tricky to find a place where this information should live and where it's truly useful for MDN readers. There's some options:

In general, the linked PR in content is making it more explicit in responses where there should be no content, which is the standard way if all is well. The information we're trying to capture or re-home is "how much junk data browsers tolerate in responses that shouldn't have a body", which seems to be interesting mostly to people implementing clients with legacy interop more than anything else.

@hamishwillee what do you think about this? Any objections to putting this in content with a list of response statuses that shouldn't include a body?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:http Compat data for HTTP features. https://developer.mozilla.org/docs/Web/HTTP size:m [PR only] 25-100 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants