1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

fix(ext/node): allow null value for req.setHeader (#21391)

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Yoshiya Hinosawa 2023-12-08 17:43:19 +09:00 committed by GitHub
parent 2b3daa690d
commit 3a74fa60ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -835,3 +835,22 @@ Deno.test("[node/https] node:https exports globalAgent", async () => {
"node:https must export 'globalAgent' on module default export",
);
});
Deno.test("[node/http] node:http request.setHeader(header, null) doesn't throw", () => {
{
const req = http.request("http://localhost:4545/");
req.on("error", () => {});
// @ts-expect-error - null is not a valid header value
req.setHeader("foo", null);
req.end();
req.destroy();
}
{
const req = https.request("https://localhost:4545/");
req.on("error", () => {});
// @ts-expect-error - null is not a valid header value
req.setHeader("foo", null);
req.end();
req.destroy();
}
});

View file

@ -249,7 +249,7 @@ export class OutgoingMessage extends Stream {
}
name = name.toString();
headers[name.toLowerCase()] = [name, value.toString()];
headers[name.toLowerCase()] = [name, String(value)];
return this;
}