1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

test(ext/node): check hostname option has precedence over host option (#25292)

This commit is contained in:
Yoshiya Hinosawa 2024-08-30 13:25:33 +09:00 committed by GitHub
parent 768132b85f
commit d71eebba0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ import url from "node:url";
import https from "node:https";
import net from "node:net";
import fs from "node:fs";
import { text } from "node:stream/consumers";
import { assert, assertEquals, fail } from "@std/assert";
import { assertSpyCalls, spy } from "@std/testing/mock";
@ -1586,3 +1587,20 @@ Deno.test("[node/http] ClientRequest content-disposition header works", async ()
assertEquals(body, "hello world");
assertEquals(headers["content-disposition"], "attachment");
});
Deno.test("[node/http] In ClientRequest, option.hostname has precedence over options.host", async () => {
const responseReceived = Promise.withResolvers<void>();
new http.ClientRequest({
hostname: "localhost",
host: "invalid-hostname.test",
port: 4545,
path: "/http_version",
}).on("response", async (res) => {
assertEquals(res.statusCode, 200);
assertEquals(await text(res), "HTTP/1.1");
responseReceived.resolve();
}).end();
await responseReceived.promise;
});