diff options
author | 2023-07-10 21:35:10 +0900 | |
---|---|---|
committer | 2023-07-10 21:35:10 +0900 | |
commit | c6e113554832d17a0736fea7491c0985705b7cd9 (patch) | |
tree | a73a4dceaa11846917fc0758251d43c8118063bb | |
parent | 59570fe237f91dd04ce8f37779902cffa4352010 (diff) | |
download | bun-c6e113554832d17a0736fea7491c0985705b7cd9.tar.gz bun-c6e113554832d17a0736fea7491c0985705b7cd9.tar.zst bun-c6e113554832d17a0736fea7491c0985705b7cd9.zip |
call `writeHead` before send headers
Close: #3585
-rw-r--r-- | src/js/node/http.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 15b060d5f..0c42b247b 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -948,7 +948,10 @@ export class ServerResponse extends Writable { #finished = false; // Express "compress" package uses this - _implicitHeader() {} + _implicitHeader() { + const statusMessage = this.statusMessage ?? STATUS_CODES[this.statusCode]; + this.writeHead(this.statusCode, statusMessage, {}); + } _write(chunk, encoding, callback) { if (!this.#firstWrite && !this.headersSent) { @@ -1015,6 +1018,7 @@ export class ServerResponse extends Writable { var data = this.#firstWrite || ""; this.#firstWrite = undefined; this.#finished = true; + this._implicitHeader(); this._reply( new Response(data, { headers: this.#headers, |