Intent to Ship: Fetch: Headers.getSetCookie()

473 views
Skip to first unread message

Andreu Botella

unread,
Feb 10, 2023, 1:05:40 PM2/10/23
to blin...@chromium.org

Contact emails

abot...@igalia.com, ri...@chromium.org

Explainer

None

Specification

https://fetch.spec.whatwg.org/#dom-headers-getsetcookie

Design docs


https://github.com/whatwg/fetch/issues/973#issuecomment-902578584
https://github.com/whatwg/fetch/issues/973#issuecomment-954815921

Summary

Adds a way to get the values of multiple Set-Cookie headers without combining them. In HTTP, Set-Cookie is a special header for historical reasons because it can appear multiple times in a response but cannot be combined, unlike other headers. Headers objects don't currently support having multiple values of the Set-Cookie header, and this feature adds that capability.



Blink component

Blink>Network>FetchAPI

Search tags

fetch, headers, cookie, Set-Cookie

TAG review



TAG review status

Not applicable, since the specification has already been changed to include this feature

Risks



Interoperability and Compatibility

The interoperability risks are low, since this feature is currently being implemented in all browser engines. This feature introduces one change to the existing iteration behavior of Headers instances, in that they may now yield multiple entries for Set-Cookie headers, when previously all Set-Cookie headers were combined in a single iteration entry. Given that this is only observable with user-created Headers objects, rather than with ones associated with Request and Response objects, this risk can be considered negligible.



Gecko: In development (https://phabricator.services.mozilla.com/D167897)

WebKit: In development (https://github.com/WebKit/WebKit/pull/9490)

Web developers: No signals

Other signals: Server-side JavaScript runtimes have been pushing this proposal as part of the Web-interoperable Runtime Community Group (WinterCG), since it allows them to use fetch-compatible HTTP server APIs. In particular, Deno was involved in writing the spec change (https://github.com/whatwg/fetch/issues/973), and both Cloudflare Workers (https://github.com/whatwg/fetch/pull/1346#pullrequestreview-797738368) and Node.js (https://github.com/whatwg/fetch/pull/1346#issuecomment-1171502837) were supportive.

Security

Set-Cookie headers are forbidden request and response headers (https://fetch.spec.whatwg.org/#forbidden-request-header, https://fetch.spec.whatwg.org/#forbidden-response-header-name), meaning that Set-Cookie headers are filtered off of Request and Response objects. This feature does not change that, and therefore does not introduce any possible information leaks.



WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

N/A



Debuggability

No DevTools support required, since this feature does not change the behavior of Set-Cookie headers in network requests/responses, or otherwise affect any aspect of the network stack.



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes

Is this feature fully tested by web-platform-tests?

Yes

Flag name



Requires code in //chrome?

False

Tracking bug

https://bugs.chromium.org/p/chromium/issues/detail?id=1409512

Estimated milestones

No milestones specified



Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

N/A

Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5184534394437632

This intent message was generated by Chrome Platform Status.

Philip Jägenstedt

unread,
Feb 14, 2023, 11:09:24 AM2/14/23
to Andreu Botella, blin...@chromium.org
LGTM1

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/63b8727a-9f01-e69d-f9b9-c46c2e1a8cbb%40igalia.com.

Yoav Weiss

unread,
Feb 15, 2023, 9:49:34 AM2/15/23
to Andreu Botella, blin...@chromium.org
On Fri, Feb 10, 2023 at 7:05 PM Andreu Botella <abot...@igalia.com> wrote:

Contact emails

abot...@igalia.com, ri...@chromium.org

Explainer

None

An explainer (or even an inline explanation of how developers are supposed to use this) would've been helpful here. As is, I don't understand what the implications of shipping this are.
 


Specification

https://fetch.spec.whatwg.org/#dom-headers-getsetcookie

Design docs


https://github.com/whatwg/fetch/issues/973#issuecomment-902578584
https://github.com/whatwg/fetch/issues/973#issuecomment-954815921

Summary

Adds a way to get the values of multiple Set-Cookie headers without combining them. In HTTP, Set-Cookie is a special header for historical reasons because it can appear multiple times in a response but cannot be combined, unlike other headers. Headers objects don't currently support having multiple values of the Set-Cookie header, and this feature adds that capability.



Blink component

Blink>Network>FetchAPI

Search tags

fetch, headers, cookie, Set-Cookie

TAG review



TAG review status

Not applicable, since the specification has already been changed to include this feature

Risks



Interoperability and Compatibility

The interoperability risks are low, since this feature is currently being implemented in all browser engines. This feature introduces one change to the existing iteration behavior of Headers instances, in that they may now yield multiple entries for Set-Cookie headers, when previously all Set-Cookie headers were combined in a single iteration entry. Given that this is only observable with user-created Headers objects, rather than with ones associated with Request and Response objects, this risk can be considered negligible.



Gecko: In development (https://phabricator.services.mozilla.com/D167897)

WebKit: In development (https://github.com/WebKit/WebKit/pull/9490)

Web developers: No signals

Other signals: Server-side JavaScript runtimes have been pushing this proposal as part of the Web-interoperable Runtime Community Group (WinterCG), since it allows them to use fetch-compatible HTTP server APIs. In particular, Deno was involved in writing the spec change (https://github.com/whatwg/fetch/issues/973), and both Cloudflare Workers (https://github.com/whatwg/fetch/pull/1346#pullrequestreview-797738368) and Node.js (https://github.com/whatwg/fetch/pull/1346#issuecomment-1171502837) were supportive.

So this is something that the backend community is interested in, but that is of no real interest to the front-end community?
 


Security

Set-Cookie headers are forbidden request and response headers (https://fetch.spec.whatwg.org/#forbidden-request-header, https://fetch.spec.whatwg.org/#forbidden-response-header-name), meaning that Set-Cookie headers are filtered off of Request and Response objects. This feature does not change that, and therefore does not introduce any possible information leaks.



WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

N/A



Debuggability

No DevTools support required, since this feature does not change the behavior of Set-Cookie headers in network requests/responses, or otherwise affect any aspect of the network stack.



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes

Is this feature fully tested by web-platform-tests?

Yes

Flag name



Requires code in //chrome?

False

Tracking bug

https://bugs.chromium.org/p/chromium/issues/detail?id=1409512

Estimated milestones

No milestones specified



Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

N/A

Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5184534394437632

This intent message was generated by Chrome Platform Status.

--

slightlyoff via Chromestatus

unread,
Feb 22, 2023, 11:29:35 AM2/22/23
to blin...@chromium.org
LGTM2

Rick Byers

unread,
Feb 22, 2023, 11:39:39 AM2/22/23
to slightlyoff via Chromestatus, blin...@chromium.org
LGTM3

On Wed, Feb 22, 2023 at 11:29 AM slightlyoff via Chromestatus <admin+sl...@cr-status.appspotmail.com> wrote:
LGTM2

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Andreu Botella

unread,
Feb 23, 2023, 4:14:19 AM2/23/23
to Yoav Weiss, blin...@chromium.org

Sorry for taking so long to reply.

One possible client-side use case enabled by this addition is as part of a JS API for a proxy, possibly one that allows access to public servers that aren't CORS-accessible:

// example.com doesn't support CORS!
const {headers, body} = proxyFetch("https://example.com");
console.log(headers.getSetCookie());


Such an API would allow access to any Set-Cookie headers sent by example.com, by encoding them somehow in non-filtered headers or in the response body. Such a returned Headers object wouldn't come directly from fetch, but it would still be a representation of HTTP headers.

But you're right that this API would be most useful for server-side runtimes that don't do CORS or filter Set-Cookie headers because they have a different security model than the web.

Andreu

Yoav Weiss

unread,
Feb 23, 2023, 4:24:16 AM2/23/23
to Andreu Botella, blin...@chromium.org
On Thu, Feb 23, 2023 at 10:14 AM Andreu Botella <abot...@igalia.com> wrote:

Sorry for taking so long to reply.

One possible client-side use case enabled by this addition is as part of a JS API for a proxy, possibly one that allows access to public servers that aren't CORS-accessible:

// example.com doesn't support CORS!
const {headers, body} = proxyFetch("https://example.com");
console.log(headers.getSetCookie());


Such an API would allow access to any Set-Cookie headers sent by example.com, by encoding them somehow in non-filtered headers or in the response body. Such a returned Headers object wouldn't come directly from fetch, but it would still be a representation of HTTP headers.

What's `proxyFetch` in that example? Is that a fetch() from a server-side proxy that's considered same-origin from the browser's perspective?

Andreu Botella

unread,
Feb 23, 2023, 4:35:34 AM2/23/23
to Yoav Weiss, blin...@chromium.org

Yes, I was thinking of proxyFetch as an API that wraps over a call to a proxy, such that you could pass and get Headers objects that correspond directly to the "raw" headers of the proxied request and response. The proxyFetch function would then encode and decode those "raw" headers somehow in the actual connection with the proxy server, so they aren't filtered out.

Reply all
Reply to author
Forward
0 new messages