mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
test(ext/node): check hostname option has precedence over host option (#25292)
This commit is contained in:
parent
34b58949b2
commit
f3e0d98b1f
1 changed files with 18 additions and 0 deletions
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue