diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2024-08-30 13:25:33 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-30 13:25:33 +0900 |
commit | d71eebba0d1ddc43aaf1e0c41f459deebaddc9f7 (patch) | |
tree | fe82ba0947136d99f5be1378b9add23c8fb9fb96 /tests/unit_node/http_test.ts | |
parent | 768132b85f2bc013275d925e2127669f91a0c7c6 (diff) |
test(ext/node): check hostname option has precedence over host option (#25292)
Diffstat (limited to 'tests/unit_node/http_test.ts')
-rw-r--r-- | tests/unit_node/http_test.ts | 18 |
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; +}); |