Skip to content

Document mutable headers on Response.json() - #45665

Closed
deerred643-star wants to merge 1 commit into
mdn:mainfrom
deerred643-star:docs/response-json-mutable
Closed

deerred643-star wants to merge 1 commit into
mdn:mainfrom
deerred643-star:docs/response-json-mutable

Conversation

@deerred643-star

Copy link
Copy Markdown

Description

Document that the headers on a response created by Response.json() are mutable, contrast them with the immutable headers on a fetched response, and demonstrate changing a header.

Motivation

Readers currently have no indication that they can modify the headers after creating a JSON response.

Additional details

The Fetch Standard creates the response with a response headers guard. The proposed change for Response.redirect() is still pending in whatwg/fetch#1944, so this PR intentionally documents only the behavior that is already specified.

Related issues and pull requests

Relates to mdn/mdn#858.

@deerred643-star
deerred643-star requested a review from a team as a code owner September 13, 2026 01:21
@deerred643-star
deerred643-star requested review from sideshowbarker and removed request for a team September 13, 2026 01:21
@github-actions github-actions Bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Sep 13, 2026
@sideshowbarker
sideshowbarker removed their request for review September 14, 2026 12:34
@Josh-Cena
Josh-Cena requested a review from wbamberg September 17, 2026 00:38
@wbamberg

Copy link
Copy Markdown
Collaborator

I think this PR over-emphasises the mutable thing. Header mutability is already documented in https://developer.mozilla.org/en-US/docs/Web/API/Headers#modification_restrictions, so I don't really think it is needed here, and if it were needed, it should be done consistently across all the places that can give you a Response.

But even then, this PR makes it seem as if header mutability is the main point of the API, by for instance describing the return value as "A {{domxref("Response")}} object whose {{domxref("Response.headers", "headers")}} are mutable.". But that's really a detail about the API AFAICS.

@wbamberg wbamberg closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants