@@ -70,9 +70,7 @@ function OutgoingMessage() {
70
70
71
71
// Queue that holds all currently pending data, until the response will be
72
72
// assigned to the socket (until it will its turn in the HTTP pipeline).
73
- this . output = [ ] ;
74
- this . outputEncodings = [ ] ;
75
- this . outputCallbacks = [ ] ;
73
+ this . outputData = [ ] ;
76
74
77
75
// `outputSize` is an approximate measure of how much data is queued on this
78
76
// response. `_onPendingData` will be invoked to update similar global
@@ -220,14 +218,18 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
220
218
data = this . _header + data ;
221
219
} else {
222
220
var header = this . _header ;
223
- if ( this . output . length === 0 ) {
224
- this . output = [ header ] ;
225
- this . outputEncodings = [ 'latin1' ] ;
226
- this . outputCallbacks = [ null ] ;
221
+ if ( this . outputData . length === 0 ) {
222
+ this . outputData = [ {
223
+ data : header ,
224
+ encoding : 'latin1' ,
225
+ callback : null
226
+ } ] ;
227
227
} else {
228
- this . output . unshift ( header ) ;
229
- this . outputEncodings . unshift ( 'latin1' ) ;
230
- this . outputCallbacks . unshift ( null ) ;
228
+ this . outputData . unshift ( {
229
+ data : header ,
230
+ encoding : 'latin1' ,
231
+ callback : null
232
+ } ) ;
231
233
}
232
234
this . outputSize += header . length ;
233
235
this . _onPendingData ( header . length ) ;
@@ -254,7 +256,7 @@ function _writeRaw(data, encoding, callback) {
254
256
255
257
if ( conn && conn . _httpMessage === this && conn . writable && ! conn . destroyed ) {
256
258
// There might be pending data in the this.output buffer.
257
- if ( this . output . length ) {
259
+ if ( this . outputData . length ) {
258
260
this . _flushOutput ( conn ) ;
259
261
} else if ( ! data . length ) {
260
262
if ( typeof callback === 'function' ) {
@@ -273,9 +275,7 @@ function _writeRaw(data, encoding, callback) {
273
275
return conn . write ( data , encoding , callback ) ;
274
276
}
275
277
// Buffer, as long as we're not destroyed.
276
- this . output . push ( data ) ;
277
- this . outputEncodings . push ( encoding ) ;
278
- this . outputCallbacks . push ( callback ) ;
278
+ this . outputData . push ( { data, encoding, callback } ) ;
279
279
this . outputSize += data . length ;
280
280
this . _onPendingData ( data . length ) ;
281
281
return false ;
@@ -738,7 +738,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
738
738
// There is the first message on the outgoing queue, and we've sent
739
739
// everything to the socket.
740
740
debug ( 'outgoing message end.' ) ;
741
- if ( this . output . length === 0 &&
741
+ if ( this . outputData . length === 0 &&
742
742
this . connection &&
743
743
this . connection . _httpMessage === this ) {
744
744
this . _finish ( ) ;
@@ -793,22 +793,19 @@ OutgoingMessage.prototype._flush = function _flush() {
793
793
794
794
OutgoingMessage . prototype . _flushOutput = function _flushOutput ( socket ) {
795
795
var ret ;
796
- var outputLength = this . output . length ;
796
+ var outputLength = this . outputData . length ;
797
797
if ( outputLength <= 0 )
798
798
return ret ;
799
799
800
- var output = this . output ;
801
- var outputEncodings = this . outputEncodings ;
802
- var outputCallbacks = this . outputCallbacks ;
800
+ var outputData = this . outputData ;
803
801
socket . cork ( ) ;
804
802
for ( var i = 0 ; i < outputLength ; i ++ ) {
805
- ret = socket . write ( output [ i ] , outputEncodings [ i ] , outputCallbacks [ i ] ) ;
803
+ const { data, encoding, callback } = outputData [ i ] ;
804
+ ret = socket . write ( data , encoding , callback ) ;
806
805
}
807
806
socket . uncork ( ) ;
808
807
809
- this . output = [ ] ;
810
- this . outputEncodings = [ ] ;
811
- this . outputCallbacks = [ ] ;
808
+ this . outputData = [ ] ;
812
809
this . _onPendingData ( - this . outputSize ) ;
813
810
this . outputSize = 0 ;
814
811
0 commit comments