Skip to content

Commit

Permalink
chore(npm): update dependency undici to v6.14.1 (#807)
Browse files Browse the repository at this point in the history
* chore(npm): update dependency undici to v6.14.1

* chore: fix types for undici v6.7.0
* related: nodejs/undici#2708

* chore: fix types for undici v6.12.0
* related: nodejs/undici#3050

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: 3846masa <3846masahiro+git@gmail.com>
  • Loading branch information
renovate[bot] and 3846masa committed May 2, 2024
1 parent 53dd11d commit 6cbdf2d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"superagent": "9.0.1",
"tough-cookie": "4.1.3",
"typescript": "5.4.5",
"undici": "6.6.2",
"undici": "6.14.1",
"urllib": "3.24.0"
},
"peerDependencies": {
Expand Down
21 changes: 7 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/undici/cookie_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CookieHandler implements Required<Dispatcher.DispatchHandlers> {
this[kHandlers].onUpgrade?.(statusCode, headers, socket);
};

onHeaders = (statusCode: number, _headers: string[] | null, resume: () => void, statusText: string): boolean => {
onHeaders = (statusCode: number, _headers: Buffer[], resume: () => void, statusText: string): boolean => {
if (this[kHandlers].onHeaders == null) {
throw new errors.InvalidArgumentError('invalid onHeaders method');
}
Expand Down
15 changes: 14 additions & 1 deletion src/undici/utils/convert_to_headers_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
import { errors } from 'undici';
import type { IncomingHttpHeaders } from 'undici/types/header';

function isIterable(value: unknown): value is Iterable<unknown> {
return typeof value === 'object' && value != null && Symbol.iterator in value;
}

function convertToHeadersObject(
_headers: IncomingHttpHeaders | (string | Buffer)[] | null | undefined,
_headers:
| IncomingHttpHeaders
| (string | Buffer)[]
| Iterable<[string, string | string[] | undefined]>
| null
| undefined,
): IncomingHttpHeaders {
const headers: IncomingHttpHeaders = {};

Expand All @@ -27,6 +36,10 @@ function convertToHeadersObject(
}
}
}
} else if (isIterable(_headers)) {
for (const [key, value] of _headers) {
headers[key.toLowerCase()] = value;
}
} else if (_headers != null) {
for (const [key, value] of Object.entries(_headers)) {
headers[key.toLowerCase()] = value;
Expand Down

0 comments on commit 6cbdf2d

Please sign in to comment.