@@ -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
@@ -219,14 +217,18 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
219
217
data = this . _header + data ;
220
218
} else {
221
219
var header = this . _header ;
222
- if ( this . output . length === 0 ) {
223
- this . output = [ header ] ;
224
- this . outputEncodings = [ 'latin1' ] ;
225
- this . outputCallbacks = [ null ] ;
220
+ if ( this . outputData . length === 0 ) {
221
+ this . outputData = [ {
222
+ data : header ,
223
+ encoding : 'latin1' ,
224
+ callback : null
225
+ } ] ;
226
226
} else {
227
- this . output . unshift ( header ) ;
228
- this . outputEncodings . unshift ( 'latin1' ) ;
229
- this . outputCallbacks . unshift ( null ) ;
227
+ this . outputData . unshift ( {
228
+ data : header ,
229
+ encoding : 'latin1' ,
230
+ callback : null
231
+ } ) ;
230
232
}
231
233
this . outputSize += header . length ;
232
234
this . _onPendingData ( header . length ) ;
@@ -253,7 +255,7 @@ function _writeRaw(data, encoding, callback) {
253
255
254
256
if ( conn && conn . _httpMessage === this && conn . writable && ! conn . destroyed ) {
255
257
// There might be pending data in the this.output buffer.
256
- if ( this . output . length ) {
258
+ if ( this . outputData . length ) {
257
259
this . _flushOutput ( conn ) ;
258
260
} else if ( ! data . length ) {
259
261
if ( typeof callback === 'function' ) {
@@ -272,9 +274,7 @@ function _writeRaw(data, encoding, callback) {
272
274
return conn . write ( data , encoding , callback ) ;
273
275
}
274
276
// Buffer, as long as we're not destroyed.
275
- this . output . push ( data ) ;
276
- this . outputEncodings . push ( encoding ) ;
277
- this . outputCallbacks . push ( callback ) ;
277
+ this . outputData . push ( { data, encoding, callback } ) ;
278
278
this . outputSize += data . length ;
279
279
this . _onPendingData ( data . length ) ;
280
280
return false ;
@@ -737,7 +737,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
737
737
// There is the first message on the outgoing queue, and we've sent
738
738
// everything to the socket.
739
739
debug ( 'outgoing message end.' ) ;
740
- if ( this . output . length === 0 &&
740
+ if ( this . outputData . length === 0 &&
741
741
this . connection &&
742
742
this . connection . _httpMessage === this ) {
743
743
this . _finish ( ) ;
@@ -792,22 +792,19 @@ OutgoingMessage.prototype._flush = function _flush() {
792
792
793
793
OutgoingMessage . prototype . _flushOutput = function _flushOutput ( socket ) {
794
794
var ret ;
795
- var outputLength = this . output . length ;
795
+ var outputLength = this . outputData . length ;
796
796
if ( outputLength <= 0 )
797
797
return ret ;
798
798
799
- var output = this . output ;
800
- var outputEncodings = this . outputEncodings ;
801
- var outputCallbacks = this . outputCallbacks ;
799
+ var outputData = this . outputData ;
802
800
socket . cork ( ) ;
803
801
for ( var i = 0 ; i < outputLength ; i ++ ) {
804
- ret = socket . write ( output [ i ] , outputEncodings [ i ] , outputCallbacks [ i ] ) ;
802
+ const { data, encoding, callback } = outputData [ i ] ;
803
+ ret = socket . write ( data , encoding , callback ) ;
805
804
}
806
805
socket . uncork ( ) ;
807
806
808
- this . output = [ ] ;
809
- this . outputEncodings = [ ] ;
810
- this . outputCallbacks = [ ] ;
807
+ this . outputData = [ ] ;
811
808
this . _onPendingData ( - this . outputSize ) ;
812
809
this . outputSize = 0 ;
813
810
0 commit comments