Skip to content

Commit f68fee8

Browse files
committed
add test
1 parent 3024443 commit f68fee8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/unit_node/http_test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// deno-lint-ignore-file no-console
44

5-
import EventEmitter from "node:events";
5+
import { EventEmitter, once } from "node:events";
66
import http, {
77
IncomingMessage,
88
type RequestOptions,
@@ -11,7 +11,7 @@ import http, {
1111
import url from "node:url";
1212
import https from "node:https";
1313
import zlib from "node:zlib";
14-
import net, { Socket } from "node:net";
14+
import net, { type AddressInfo, Socket } from "node:net";
1515
import fs from "node:fs";
1616
import { text } from "node:stream/consumers";
1717

@@ -441,6 +441,19 @@ Deno.test("[node/http] request with headers", async () => {
441441
await promise;
442442
});
443443

444+
Deno.test("[node/http] request with ipv6 host", async () => {
445+
const server = http.createServer((_req, res) => res.end()).listen(0, "::1");
446+
await once(server, "listening");
447+
const { port } = server.address() as AddressInfo;
448+
const req = http.request(`http://[::1]:${port}`);
449+
const [res] = await once(req, "response") as [IncomingMessage];
450+
assertEquals(res.statusCode, 200);
451+
res.resume();
452+
await once(res, "end");
453+
server.close();
454+
await once(server, "close");
455+
});
456+
444457
Deno.test("[node/http] non-string buffer response", {
445458
// TODO(kt3k): Enable sanitizer. A "zlib" resource is leaked in this test case.
446459
sanitizeResources: false,

0 commit comments

Comments
 (0)