@@ -70,9 +70,7 @@ function OutgoingMessage() {
7070
7171 // Queue that holds all currently pending data, until the response will be
7272 // 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 = [ ] ;
7674
7775 // `outputSize` is an approximate measure of how much data is queued on this
7876 // response. `_onPendingData` will be invoked to update similar global
@@ -219,14 +217,18 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
219217 data = this . _header + data ;
220218 } else {
221219 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+ } ] ;
226226 } 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+ } ) ;
230232 }
231233 this . outputSize += header . length ;
232234 this . _onPendingData ( header . length ) ;
@@ -253,7 +255,7 @@ function _writeRaw(data, encoding, callback) {
253255
254256 if ( conn && conn . _httpMessage === this && conn . writable && ! conn . destroyed ) {
255257 // There might be pending data in the this.output buffer.
256- if ( this . output . length ) {
258+ if ( this . outputData . length ) {
257259 this . _flushOutput ( conn ) ;
258260 } else if ( ! data . length ) {
259261 if ( typeof callback === 'function' ) {
@@ -272,9 +274,7 @@ function _writeRaw(data, encoding, callback) {
272274 return conn . write ( data , encoding , callback ) ;
273275 }
274276 // 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 } ) ;
278278 this . outputSize += data . length ;
279279 this . _onPendingData ( data . length ) ;
280280 return false ;
@@ -737,7 +737,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
737737 // There is the first message on the outgoing queue, and we've sent
738738 // everything to the socket.
739739 debug ( 'outgoing message end.' ) ;
740- if ( this . output . length === 0 &&
740+ if ( this . outputData . length === 0 &&
741741 this . connection &&
742742 this . connection . _httpMessage === this ) {
743743 this . _finish ( ) ;
@@ -792,22 +792,19 @@ OutgoingMessage.prototype._flush = function _flush() {
792792
793793OutgoingMessage . prototype . _flushOutput = function _flushOutput ( socket ) {
794794 var ret ;
795- var outputLength = this . output . length ;
795+ var outputLength = this . outputData . length ;
796796 if ( outputLength <= 0 )
797797 return ret ;
798798
799- var output = this . output ;
800- var outputEncodings = this . outputEncodings ;
801- var outputCallbacks = this . outputCallbacks ;
799+ var outputData = this . outputData ;
802800 socket . cork ( ) ;
803801 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 ) ;
805804 }
806805 socket . uncork ( ) ;
807806
808- this . output = [ ] ;
809- this . outputEncodings = [ ] ;
810- this . outputCallbacks = [ ] ;
807+ this . outputData = [ ] ;
811808 this . _onPendingData ( - this . outputSize ) ;
812809 this . outputSize = 0 ;
813810
0 commit comments