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

Missing Headers.entries #25

Closed
pi0 opened this issue Nov 2, 2023 · 5 comments
Closed

Missing Headers.entries #25

pi0 opened this issue Nov 2, 2023 · 5 comments

Comments

@pi0
Copy link

pi0 commented Nov 2, 2023

(context: from nitrojs/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.

@Arshia001
Copy link
Member

Arshia001 commented Nov 2, 2023

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).

@Arshia001 Arshia001 changed the title Missing Headers.entities Missing Headers.entries Nov 2, 2023
@syrusakbary
Copy link
Member

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

@syrusakbary
Copy link
Member

We made the decision to follow Cloudflare Workers, and implement Headers.entries

@Arshia001
Copy link
Member

I've added the method in, will be available with the next version.

@pi0
Copy link
Author

pi0 commented Nov 2, 2023

Thanks!

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

No branches or pull requests

3 participants