@@ -555,7 +555,7 @@ class Parser extends HTTPParser {
555555
556556 try {
557557 if ( request . onBody ( chunk , offset , length ) === false ) {
558- socket . pause ( )
558+ socket [ kPause ] ( )
559559 }
560560 } catch ( err ) {
561561 util . destroy ( socket , err )
@@ -630,7 +630,7 @@ class Parser extends HTTPParser {
630630 util . destroy ( socket , new InformationalError ( 'reset' ) )
631631 }
632632 } else {
633- socket . resume ( )
633+ socket [ kResume ] ( )
634634 resume ( client )
635635 }
636636 }
@@ -779,8 +779,8 @@ function connect (client) {
779779 parser . consume ( socket . _handle . _externalStream )
780780 }
781781
782- socket [ kPause ] = socket . pause . bind ( socket )
783- socket [ kResume ] = socket . resume . bind ( socket )
782+ socket [ kPause ] = socketPause . bind ( socket )
783+ socket [ kResume ] = socketResume . bind ( socket )
784784 socket [ kError ] = null
785785 socket [ kParser ] = parser
786786 socket [ kClient ] = client
@@ -794,6 +794,20 @@ function connect (client) {
794794 . on ( 'close' , onSocketClose )
795795}
796796
797+ function socketPause ( ) {
798+ if ( this . _handle && this . _handle . reading ) {
799+ this . _handle . reading = false
800+ this . _handle . readStop ( )
801+ }
802+ }
803+
804+ function socketResume ( ) {
805+ if ( this . _handle && ! this . _handle . reading ) {
806+ this . _handle . reading = true
807+ this . _handle . readStart ( )
808+ }
809+ }
810+
797811function emitDrain ( client ) {
798812 client [ kNeedDrain ] = 0
799813 client . emit ( 'drain' )
0 commit comments