From d799c0f17921797eb61088f6740b25b70d54571e Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 1 May 2020 17:17:37 +0200 Subject: [PATCH] http: simplify sending header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unshifting into an empty array is the same as creating a new array. PR-URL: https://github.com/nodejs/node/pull/33200 Reviewed-By: Juan José Arboleda Reviewed-By: James M Snell Reviewed-By: Zeyu Yang Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- lib/_http_outgoing.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index a22621ea431..5fd462b0194 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -304,19 +304,11 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) { data = this._header + data; } else { const header = this._header; - if (this.outputData.length === 0) { - this.outputData = [{ - data: header, - encoding: 'latin1', - callback: null - }]; - } else { - this.outputData.unshift({ - data: header, - encoding: 'latin1', - callback: null - }); - } + this.outputData.unshift({ + data: header, + encoding: 'latin1', + callback: null + }); this.outputSize += header.length; this._onPendingData(header.length); }