[whatwg/fetch] Cloned responses should not have immutable headers (#608)

https://fetch.spec.whatwg.org/commit-snapshots/0bcd5dfc71ef44319873887f4b83119bd6d0b71d/#response-class

> Upon fulfillment of context object’s trailer promise, resolve clonedResponseObject’s trailer promise with a new Headers object whose guard is "immutable", and whose header list is clonedResponse’s trailer\.

When cloning a response via `response.clone()`, the headers are spec'ed to be immutable, and if you try to modify them, you get an error.

I'd like to prepose that we change this behavior. The primary use case I'm trying to solve is adding custom metadata to a response for analytics purposes (to distinguish a response served from the cache vs. a response that required a network fetch).

You can work around this today by creating a clone of the response and then manually making a copy of that clone, e.g. `new Response(await responseClone.text(), responseClone)`, but this is a lot of work to just modify headers.

Since I *can* work around the immutable headers issue in this way, I'm not sure what protection it's offering.




-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/608

Received on Tuesday, 26 September 2017 16:59:39 UTC