mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
http: simplify sending header
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 <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>
This commit is contained in:
parent
53eb264cb1
commit
d799c0f179
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user