From 25a3204fe29a8470f5a90a6bf424059757a09363 Mon Sep 17 00:00:00 2001 From: Dimitris Halatsis Date: Fri, 15 Jan 2021 12:11:31 +0200 Subject: [PATCH] http: don't cork .end when not needed PR-URL: https://github.com/nodejs/node/pull/36633 Backport-PR-URL: https://github.com/nodejs/node/pull/36940 Fixes: https://github.com/nodejs/node/issues/36620 Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum Reviewed-By: Danielle Adams --- lib/_http_outgoing.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index e3a032ad21273b..c8a393ddcf31b4 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -775,7 +775,8 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) { encoding = null; } - if (this.socket) { + // Not finished, socket exists and data will be written (chunk or header) + if (this.socket && !this.finished && (chunk || !this._header)) { this.socket.cork(); }