1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

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
This commit is contained in:
Divy Srivastava 2023-12-11 10:16:12 +05:30 committed by GitHub
parent 67eec26308
commit e8fc7c20b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -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";

View file

@ -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);