diff options
Diffstat (limited to 'ext/node/polyfills/http.ts')
-rw-r--r-- | ext/node/polyfills/http.ts | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 52aac4cae..1103e93c3 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -566,7 +566,9 @@ class ClientRequest extends OutgoingMessage { } }*/ this.onSocket(new FakeSocket({ encrypted: this._encrypted })); + } + _writeHeader() { const url = this._createUrlStrFromOptions(); const headers = []; @@ -585,12 +587,22 @@ class ClientRequest extends OutgoingMessage { url, headers, client.rid, - this.method === "POST" || this.method === "PATCH" || - this.method === "PUT", + (this.method === "POST" || this.method === "PATCH" || + this.method === "PUT") && this._contentLength !== 0, ); this._bodyWriteRid = this._req.requestBodyRid; } + _implicitHeader() { + if (this._header) { + throw new ERR_HTTP_HEADERS_SENT("render"); + } + this._storeHeader( + this.method + " " + this.path + " HTTP/1.1\r\n", + this[kOutHeaders], + ); + } + _getClient(): Deno.HttpClient | undefined { return undefined; } @@ -615,8 +627,12 @@ class ClientRequest extends OutgoingMessage { } this.finished = true; - if (chunk !== undefined && chunk !== null) { - this.write(chunk, encoding); + if (chunk) { + this.write_(chunk, encoding, null, true); + } else if (!this._headerSent) { + this._contentLength = 0; + this._implicitHeader(); + this._send("", "latin1"); } (async () => { |