From 6efaef606af890e05deab0a892b1214f7f8421a9 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Tue, 18 Apr 2023 15:20:36 +0900 Subject: fix(ext/node): polyfill response._implicitHeader method (#18738) --- ext/node/polyfills/http.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ext/node') diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index ab5e2b438..12d71277f 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -485,7 +485,7 @@ export class ServerResponse extends NodeWritable { return this.#headers.has(name); } - writeHead(status: number, headers: Record) { + writeHead(status: number, headers: Record = {}) { this.statusCode = status; for (const k in headers) { if (Object.hasOwn(headers, k)) { @@ -540,6 +540,11 @@ export class ServerResponse extends NodeWritable { // @ts-expect-error The signature for cb is stricter than the one implemented here return super.end(chunk, encoding, cb); } + + // Undocumented API used by `npm:compression`. + _implicitHeader() { + this.writeHead(this.statusCode); + } } // TODO(@AaronO): optimize -- cgit v1.2.3