Closed pi0 closed 1 year ago
According to https://fetch.spec.whatwg.org/#headers, the headers object itself should be iterable. There is no entries
method in the standard AFAICT.
The entries
method as specified in the MDN docs can be added in via a simple polyfill:
Headers.prototype.entries = function() {
return this[Symbol.iterator]();
}
We're discussing internally how we might support non-standard APIs (the standard in question being WinterCG).
I've checked in Deno Deploy and Cloudflare Workers with this script:
self.addEventListener('fetch', event => {
let headers = event.request.headers;
event.respondWith(new Response(`typeof headers.entries == "${typeof headers.entries}"`));
})
In both cases, the response was:
typeof headers.entries == "function"
Which means that both Cloudflare Workers and Deno Deploy had this implemented. We should follow up to see if it should be in the spec
We made the decision to follow Cloudflare Workers, and implement Headers.entries
I've added the method in, will be available with the next version.
Thanks!
(context: from unjs/nitro#1861 tracker)
Tested runtime version: v0.1.7
MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/Headers/entries
Headers.entries
method seems missing.