diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-12-11 10:16:12 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 04:46:12 +0000 |
commit | e8fc7c20b754514cf99741f630751cc8bb756145 (patch) | |
tree | c21839ba4a909bc62148b1404331dca048e578bb | |
parent | 67eec263086056713cefce61ed775d126beb5390 (diff) |
fix(ext/node): stub ServerResponse#flushHeaders (#21526)
This commit adds a no-op flushHeaders method to the ServerResponse
object. It is a nop because the ServerResponse implementation is based
on top of the Deno server API instead of the Node `OutgoingMessage`
base.
Fixes #21509
-rw-r--r-- | cli/tests/unit_node/http_test.ts | 20 | ||||
-rw-r--r-- | ext/node/polyfills/http.ts | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts index ae708c343..c46a3de41 100644 --- a/cli/tests/unit_node/http_test.ts +++ b/cli/tests/unit_node/http_test.ts @@ -482,6 +482,26 @@ Deno.test("[node/http] ServerResponse _implicitHeader", async () => { await promise; }); +// https://github.com/denoland/deno/issues/21509 +Deno.test("[node/http] ServerResponse flushHeaders", async () => { + const { promise, resolve } = Promise.withResolvers<void>(); + const server = http.createServer((_req, res) => { + res.flushHeaders(); // no-op + res.end("Hello World"); + }); + + server.listen(async () => { + const { port } = server.address() as { port: number }; + const res = await fetch(`http://localhost:${port}`); + assertEquals(await res.text(), "Hello World"); + server.close(() => { + resolve(); + }); + }); + + await promise; +}); + Deno.test("[node/http] server unref", async () => { const [statusCode, _output] = await execCode(` import http from "node:http"; diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index a694c9e9b..27fc577c0 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -1459,6 +1459,10 @@ export class ServerResponse extends NodeWritable { return super.end(chunk, encoding, cb); } + flushHeaders() { + // no-op + } + // Undocumented API used by `npm:compression`. _implicitHeader() { this.writeHead(this.statusCode); |