summaryrefslogtreecommitdiff
path: root/tests/unit_node/http_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_node/http_test.ts')
-rw-r--r--tests/unit_node/http_test.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts
index a599754b9..7f5e74bf5 100644
--- a/tests/unit_node/http_test.ts
+++ b/tests/unit_node/http_test.ts
@@ -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;
+});