Skip to content

Commit f23f092

Browse files
committed
feat: header append
1 parent 28caf45 commit f23f092

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

examples/headers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ const headers2 = [
1313
const myHeaders2 = new Headers(headers2);
1414
console.log("myHeaders2", myHeaders2); // TODO Headers { 'Set-Cookie': 'greeting=hello, name=world' } but [object Object]
1515
console.log("myHeaders", myHeaders2.get("Set-Cookie")); // greeting=hellogreeting=hello,name=worldname=world
16+
17+
const myAppendHeader = new Headers();
18+
myAppendHeader.append("Content-Type", "image/jpeg");
19+
console.log("myAppendHeader", myAppendHeader.get("Content-Type")); // 'image/jpeg'

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ class Headers {
1515

1616
// https://fetch.spec.whatwg.org/#dom-headers-get
1717
get(name: string) {
18-
// @ts-ignore
1918
return getHeader(this.headerList, name);
2019
}
20+
21+
// https://fetch.spec.whatwg.org/#dom-headers-append
22+
append(name, value) {
23+
return appendHeader(this, name, value);
24+
}
2125
}
2226

2327
function fillHeaders(headers: Headers, object) {

0 commit comments

Comments
 (0)