diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-07-11 14:49:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-11 14:49:19 +0200 |
commit | 4cfc54931d765a012b7836e60ba556d9c7b421ff (patch) | |
tree | b74c0a1065436a7438f4d283c88a5aa92c19712c /ext | |
parent | be9e73d340373350c10bd30ca4f130b753287140 (diff) |
fix(node/http): allow callback in first argument of end call (#19778)
Closes #19762
Diffstat (limited to 'ext')
-rw-r--r-- | ext/node/polyfills/http.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index e3419e88b..6a1ea7105 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -599,6 +599,15 @@ class ClientRequest extends OutgoingMessage { // deno-lint-ignore no-explicit-any end(chunk?: any, encoding?: any, cb?: any): this { + if (typeof chunk === "function") { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === "function") { + cb = encoding; + encoding = null; + } + this.finished = true; if (chunk !== undefined && chunk !== null) { this.write(chunk, encoding); @@ -617,12 +626,12 @@ class ClientRequest extends OutgoingMessage { } core.tryClose(this._bodyWriteRid); + } - try { - cb?.(); - } catch (_) { - // - } + try { + cb?.(); + } catch (_) { + // } })(), ]); |