File tree Expand file tree Collapse file tree 2 files changed +10
-20
lines changed
Expand file tree Collapse file tree 2 files changed +10
-20
lines changed Original file line number Diff line number Diff line change @@ -3,20 +3,13 @@ const httpHeaders = {
33 "X-My-Custom-Header" : "Zeke are cool" ,
44} ;
55const myHeaders = new Headers ( httpHeaders ) ;
6-
76console . log ( "myHeaders" , myHeaders . get ( "Content-Type" ) ) ; // image/jpeg
87console . 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
Original file line number Diff line number Diff line change 11class 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
You can’t perform that action at this time.
0 commit comments