File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -61,9 +61,17 @@ function Server (opts) {
6161 // start an http tracker unless the user explictly says no
6262 if ( opts . http !== false ) {
6363 self . http = http . createServer ( )
64- self . http . on ( 'request' , function ( req , res ) { self . onHttpRequest ( req , res ) } )
6564 self . http . on ( 'error' , function ( err ) { self . _onError ( err ) } )
6665 self . http . on ( 'listening' , onListening )
66+
67+ // Add default http request handler on next tick to give user the chance to add
68+ // their own handler first. Handle requests untouched by user's handler.
69+ process . nextTick ( function ( ) {
70+ self . http . on ( 'request' , function ( req , res ) {
71+ if ( res . headersSent ) return
72+ self . onHttpRequest ( req , res )
73+ } )
74+ } )
6775 }
6876
6977 // start a udp tracker unless the user explicitly says no
You can’t perform that action at this time.
0 commit comments