File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -222,6 +222,14 @@ class Request {
222222 if ( channels . bodySent . hasSubscribers ) {
223223 channels . bodySent . publish ( { request : this } )
224224 }
225+
226+ if ( this [ kHandler ] . onRequestSent ) {
227+ try {
228+ this [ kHandler ] . onRequestSent ( )
229+ } catch ( err ) {
230+ this . onError ( err )
231+ }
232+ }
225233 }
226234
227235 onConnect ( abort ) {
Original file line number Diff line number Diff line change @@ -671,6 +671,8 @@ test('dispatch onBodySent not a function', (t) => {
671671} )
672672
673673test ( 'dispatch onBodySent buffer' , ( t ) => {
674+ t . plan ( 3 )
675+
674676 const server = http . createServer ( ( req , res ) => {
675677 res . end ( 'ad' )
676678 } )
@@ -688,20 +690,24 @@ test('dispatch onBodySent buffer', (t) => {
688690 onBodySent ( chunk ) {
689691 t . equal ( chunk . toString ( ) , body )
690692 } ,
693+ onRequestSent ( ) {
694+ t . pass ( )
695+ } ,
691696 onError ( err ) {
692697 throw err
693698 } ,
694699 onConnect ( ) { } ,
695700 onHeaders ( ) { } ,
696701 onData ( ) { } ,
697702 onComplete ( ) {
698- t . end ( )
703+ t . pass ( )
699704 }
700705 } )
701706 } )
702707} )
703708
704709test ( 'dispatch onBodySent stream' , ( t ) => {
710+ t . plan ( 8 )
705711 const server = http . createServer ( ( req , res ) => {
706712 res . end ( 'ad' )
707713 } )
@@ -723,6 +729,9 @@ test('dispatch onBodySent stream', (t) => {
723729 t . equal ( chunks [ currentChunk ++ ] , chunk )
724730 sentBytes += Buffer . byteLength ( chunk )
725731 } ,
732+ onRequestSent ( ) {
733+ t . pass ( )
734+ } ,
726735 onError ( err ) {
727736 throw err
728737 } ,
@@ -732,7 +741,7 @@ test('dispatch onBodySent stream', (t) => {
732741 onComplete ( ) {
733742 t . equal ( currentChunk , chunks . length )
734743 t . equal ( sentBytes , toSendBytes )
735- t . end ( )
744+ t . pass ( )
736745 }
737746 } )
738747 } )
You can’t perform that action at this time.
0 commit comments