Skip to content

Commit bb61c2c

Browse files
committed
Ensure raw/flat header logic always uses strings (Node allows numbers)
This doesn't matter for our own logic, since we should always be handling numbers, but when reading state from requests built elsewhere (from 'ws' internals) we can see numbers sometimes.
1 parent 0c2d1d9 commit bb61c2c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/util/header-utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ export function objectHeadersToRaw(headers: Headers): RawHeaders {
127127
if (value === undefined) continue; // Drop undefined header values
128128

129129
if (Array.isArray(value)) {
130-
value.forEach((v) => rawHeaders.push([key, v]));
130+
value.forEach((v) => rawHeaders.push([key, v.toString()]));
131131
} else {
132-
rawHeaders.push([key, value]);
132+
rawHeaders.push([key, value.toString()]);
133133
}
134134
}
135135

@@ -147,11 +147,11 @@ export function objectHeadersToFlat(headers: Headers): string[] {
147147
if (Array.isArray(value)) {
148148
value.forEach((v) => {
149149
flatHeaders.push(key);
150-
flatHeaders.push(v);
150+
flatHeaders.push(v.toString());
151151
});
152152
} else {
153153
flatHeaders.push(key);
154-
flatHeaders.push(value);
154+
flatHeaders.push(value.toString());
155155
}
156156
}
157157

0 commit comments

Comments
 (0)