diff options
author | 2023-08-30 10:39:12 +0800 | |
---|---|---|
committer | 2023-08-29 19:39:12 -0700 | |
commit | 3f4bc625ff2313713cf38c3c3ba036781ac1c9a9 (patch) | |
tree | 3a6077aa91fb171255e516d67780d52b2f0e1459 /test/js | |
parent | 5d84ef778066a6221630d82b7dc6b01aeddc3c26 (diff) | |
download | bun-3f4bc625ff2313713cf38c3c3ba036781ac1c9a9.tar.gz bun-3f4bc625ff2313713cf38c3c3ba036781ac1c9a9.tar.zst bun-3f4bc625ff2313713cf38c3c3ba036781ac1c9a9.zip |
parse unix socket path param in `http.server` (#4390)
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/node/http/node-http.test.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts index bacd263fa..64beba25b 100644 --- a/test/js/node/http/node-http.test.ts +++ b/test/js/node/http/node-http.test.ts @@ -11,6 +11,8 @@ import { } from "node:http"; import { createTest } from "node-harness"; import url from "node:url"; +import { tmpdir } from "node:os"; +import { spawnSync } from "node:child_process"; const { describe, expect, it, beforeAll, afterAll, createDoneDotAll } = createTest(import.meta.path); function listen(server: Server): Promise<URL> { @@ -823,4 +825,29 @@ describe("node:http", () => { } }); }); + + test("test unix socket server", done => { + const socketPath = `${tmpdir()}/bun-server-${Math.random().toString(32)}.sock`; + const server = createServer((req, res) => { + expect(req.method).toStrictEqual("GET"); + expect(req.url).toStrictEqual("/bun?a=1"); + res.writeHead(200, { + "Content-Type": "text/plain", + "Connection": "close", + }); + res.write("Bun\n"); + res.end(); + }); + + server.listen(socketPath, () => { + // TODO: unix socket is not implemented in fetch. + const output = spawnSync("curl", ["--unix-socket", socketPath, "http://localhost/bun?a=1"]); + try { + expect(output.stdout.toString()).toStrictEqual("Bun\n"); + done(); + } catch (err) { + done(err); + } + }); + }); }); |