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

Standardize access to cookie headers #4

Closed
blittle opened this issue May 12, 2022 · 5 comments
Closed

Standardize access to cookie headers #4

blittle opened this issue May 12, 2022 · 5 comments

Comments

@blittle
Copy link

blittle commented May 12, 2022

As outlined at WHATWG/fetch there is often the need in a server environment to access cookie headers.

For example editing Cookie headers:

const h = new Headers;
h.append("Set-Cookie", "a=1; Expires=Wed, 21 Oct 2015 07:28:00 GMT");
h.append("Set-Cookie", "b=1; Expires=Wed, 21 Oct 2015 07:28:00 GMT");

h.get("Set-Cookie")
// a=1; Expires=Wed, 21 Oct 2015 07:28:00 GMT, b=1; Expires=Wed, 21 Oct 2015 07:28:00 GMT

Headers.prototype.getAll would solve this problem, but was removed from the browser specification. Should we standardize on adding it back? Or should we define a new method all together? Ideally we should align with node-fetch and undici as well.

@KhafraDev
Copy link

There's a proposal to add cookieStore options to the Request and Response constructors. That could solve cookie handling issues if it's automatically propagated with any set-cookie headers. Of course, fetch implementations could also add .getAll('set-cookie') (similar to what cf workers has) and let the dev create their own CookieStore if they need to parse the cookies.

=> CookieStore spec

@lucacasonato
Copy link
Member

This is already being solved in the upstream fetch spec: whatwg#1346.

@jimmywarting
Copy link

just popping in this little side note: whatwg#1384 if a CookieStore could maybe perhaps serve as an alternative solution. of sending/reading cookies

@Ethan-Arrowood Ethan-Arrowood transferred this issue from another repository Jan 19, 2023
@balazsorban44
Copy link

Note, there is a spec now for .getSetCookie(). See https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie

@andreubotella
Copy link
Member

Indeed, with the addition to getSetCookie to upstream fetch in whatwg#1346, and this fork allowing server-side runtimes to not filter cookie headers in #19, I think this issue can now be closed.

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

6 participants