Skip to content

Commit ccb267e

Browse files
committed
chore: fix types for undici v6.7.0
* related: nodejs/undici#2708
1 parent d2c0a62 commit ccb267e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/undici/utils/convert_to_headers_object.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
import { errors } from 'undici';
33
import type { IncomingHttpHeaders } from 'undici/types/header';
44

5+
function isIterable(value: unknown): value is Iterable<unknown> {
6+
return typeof value === 'object' && value != null && Symbol.iterator in value;
7+
}
8+
59
function convertToHeadersObject(
6-
_headers: IncomingHttpHeaders | (string | Buffer)[] | null | undefined,
10+
_headers:
11+
| IncomingHttpHeaders
12+
| (string | Buffer)[]
13+
| Iterable<[string, string | string[] | undefined]>
14+
| null
15+
| undefined,
716
): IncomingHttpHeaders {
817
const headers: IncomingHttpHeaders = {};
918

@@ -27,6 +36,10 @@ function convertToHeadersObject(
2736
}
2837
}
2938
}
39+
} else if (isIterable(_headers)) {
40+
for (const [key, value] of _headers) {
41+
headers[key.toLowerCase()] = value;
42+
}
3043
} else if (_headers != null) {
3144
for (const [key, value] of Object.entries(_headers)) {
3245
headers[key.toLowerCase()] = value;

0 commit comments

Comments
 (0)