Navigation Menu

Skip to content

Commit

Permalink
http: simplify sending header
Browse files Browse the repository at this point in the history
unshifting into an empty array is the same
as creating a new array.

PR-URL: #33200
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
ronag authored and targos committed May 13, 2020
1 parent 51c3c8d commit a3decf5
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lib/_http_outgoing.js
Expand Up @@ -289,19 +289,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);
}
Expand Down

0 comments on commit a3decf5

Please sign in to comment.