Skip to content

Commit ecda905

Browse files
committed
update
1 parent 346cf7c commit ecda905

File tree

1 file changed

+15
-19
lines changed
  • runtime/src/ext/fetch/headers

1 file changed

+15
-19
lines changed

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
class Headers {
2+
#guard;
3+
// TODO: this is HeaderList type
4+
#headerList;
5+
6+
// https://fetch.spec.whatwg.org/#headers-class
27
constructor(init = undefined) {
3-
// TODO: webidl
4-
// this.brand = brand;
5-
// @ts-ignore - this is a hack to make the URL object work
6-
this.guard = "none";
7-
// @ts-ignore - this is a hack to make the URL object work
8-
this.headerList = [];
8+
// @ts-ignore
9+
this.#guard = "none";
10+
// @ts-ignore
11+
this.#headerList = [];
912
fillHeaders(this, init);
1013
}
1114

12-
get(name) {
13-
// @ts-ignore - this is a hack to make the URL object work
14-
return getHeader(this.headerList, name);
15+
// https://fetch.spec.whatwg.org/#dom-headers-get
16+
get(name: string) {
17+
// @ts-ignore
18+
return getHeader(this.#headerList, name);
1519
}
1620
}
1721

18-
function fillHeaders(headers, object) {
22+
function fillHeaders(headers: Headers, object) {
1923
if (Array.isArray(object)) {
2024
for (let i = 0; i < object.length; ++i) {
2125
const header = object[i];
@@ -36,10 +40,6 @@ function fillHeaders(headers, object) {
3640
}
3741
}
3842

39-
/**
40-
* @param {string} s
41-
* @returns {string}
42-
*/
4343
function byteLowerCase(s) {
4444
// NOTE: correct since all callers convert to ByteString first
4545
// TODO(@AaronO): maybe prefer a ByteString_Lower webidl converter
@@ -51,7 +51,7 @@ function appendHeader(headers, name, value) {
5151
// 1.
5252
value = normalizeHeaderValue(value);
5353

54-
// 2.
54+
// 2. TODO
5555
// if (!checkHeaderNameForHttpTokenCodePoint(name)) {
5656
// throw new TypeError(`Invalid header name: "${name}"`);
5757
// }
@@ -76,10 +76,6 @@ function appendHeader(headers, name, value) {
7676
list.push([name, value]);
7777
}
7878

79-
/**
80-
* @param {string} potentialValue
81-
* @returns {string}
82-
*/
8379
function normalizeHeaderValue(potentialValue) {
8480
return httpTrim(potentialValue);
8581
}

0 commit comments

Comments
 (0)