1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 00:21:05 -05:00

feat(ext/fetch): add Headers#getSetCookie (#13542)

Spec change: https://github.com/whatwg/fetch/pull/1346
Tests: https://github.com/web-platform-tests/wpt/pull/31442 (ran against
this PR and they all pass)

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Luca Casonato 2023-07-02 13:20:56 +02:00 committed by GitHub
parent 0ddfd5d52a
commit d8e8e60f9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 20 deletions

View file

@ -308,6 +308,7 @@ class Headers {
* @param {string} name
*/
delete(name) {
webidl.assertBranded(this, HeadersPrototype);
const prefix = "Failed to execute 'delete' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, prefix, "Argument 1");
@ -333,6 +334,7 @@ class Headers {
* @param {string} name
*/
get(name) {
webidl.assertBranded(this, HeadersPrototype);
const prefix = "Failed to execute 'get' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, prefix, "Argument 1");
@ -345,10 +347,25 @@ class Headers {
return getHeader(list, name);
}
getSetCookie() {
webidl.assertBranded(this, HeadersPrototype);
const list = this[_headerList];
const entries = [];
for (let i = 0; i < list.length; i++) {
if (byteLowerCase(list[i][0]) === "set-cookie") {
ArrayPrototypePush(entries, list[i][1]);
}
}
return entries;
}
/**
* @param {string} name
*/
has(name) {
webidl.assertBranded(this, HeadersPrototype);
const prefix = "Failed to execute 'has' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, prefix, "Argument 1");

View file

@ -4041,25 +4041,9 @@
"headers-record.any.worker.html": true,
"headers-structure.any.worker.html": true,
"header-setcookie.any.html": [
"Headers.prototype.getSetCookie with no headers present",
"Headers.prototype.getSetCookie with one header",
"Headers.prototype.getSetCookie with one header created from an object",
"Headers.prototype.getSetCookie with multiple headers",
"Headers.prototype.getSetCookie with an empty header",
"Headers.prototype.getSetCookie with two equal headers",
"Headers.prototype.getSetCookie ignores set-cookie2 headers",
"Headers.prototype.getSetCookie preserves header ordering",
"Set-Cookie is a forbidden response header"
],
"header-setcookie.any.worker.html": [
"Headers.prototype.getSetCookie with no headers present",
"Headers.prototype.getSetCookie with one header",
"Headers.prototype.getSetCookie with one header created from an object",
"Headers.prototype.getSetCookie with multiple headers",
"Headers.prototype.getSetCookie with an empty header",
"Headers.prototype.getSetCookie with two equal headers",
"Headers.prototype.getSetCookie ignores set-cookie2 headers",
"Headers.prototype.getSetCookie preserves header ordering",
"Set-Cookie is a forbidden response header"
]
},
@ -4890,8 +4874,6 @@
]
},
"idlharness.any.html": [
"Headers interface: operation getSetCookie()",
"Headers interface: new Headers() must inherit property \"getSetCookie()\" with the proper type",
"Request interface: attribute destination",
"Request interface: attribute referrer",
"Request interface: attribute referrerPolicy",
@ -4923,8 +4905,6 @@
"Window interface: operation fetch(RequestInfo, optional RequestInit)"
],
"idlharness.any.worker.html": [
"Headers interface: operation getSetCookie()",
"Headers interface: new Headers() must inherit property \"getSetCookie()\" with the proper type",
"Request interface: attribute destination",
"Request interface: attribute referrer",
"Request interface: attribute referrerPolicy",