Skip to content

Commit 30064ba

Browse files
committed
updte
1 parent ecda905 commit 30064ba

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

examples/headers.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@ const httpHeaders = {
33
"X-My-Custom-Header": "Zeke are cool",
44
};
55
const myHeaders = new Headers(httpHeaders);
6-
76
console.log("myHeaders", myHeaders.get("Content-Type")); // image/jpeg
87
console.log("myHeaders", myHeaders.get("X-My-Custom-Header")); // Zeke are cool
98

10-
// // Append a header to the headers object.
11-
// myHeaders.append("user-agent", "Deno Deploy");
12-
13-
// // Print the headers of the headers object.
14-
// for (const [key, value] of myHeaders.entries()) {
15-
// console.log(key, value);
16-
// }
17-
18-
// // You can pass the headers instance to Response or Request constructors.
19-
// const request = new Request("https://api.github.com/users/denoland", {
20-
// method: "POST",
21-
// headers: myHeaders,
22-
// });
9+
const headers2 = [
10+
["Set-Cookie", "greeting=hello"],
11+
["Set-Cookie", "name=world"],
12+
];
13+
const myHeaders2 = new Headers(headers2);
14+
console.log("myHeaders2", myHeaders2); // TODO Headers { 'Set-Cookie': 'greeting=hello, name=world' } but [object Object]
15+
console.log("myHeaders", myHeaders2.get("Set-Cookie")); // greeting=hellogreeting=hello,name=worldname=world

runtime/src/ext/fetch/headers/mod.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
class Headers {
2-
#guard;
32
// TODO: this is HeaderList type
4-
#headerList;
5-
63
// https://fetch.spec.whatwg.org/#headers-class
74
constructor(init = undefined) {
85
// @ts-ignore
9-
this.#guard = "none";
6+
this.guard = "none";
107
// @ts-ignore
11-
this.#headerList = [];
8+
this.headerList = [];
129
fillHeaders(this, init);
1310
}
1411

1512
// https://fetch.spec.whatwg.org/#dom-headers-get
1613
get(name: string) {
1714
// @ts-ignore
18-
return getHeader(this.#headerList, name);
15+
return getHeader(this.headerList, name);
1916
}
2017
}
2118

0 commit comments

Comments
 (0)