mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-13 10:56:25 +00:00
allow user to intercept 'request' event for http tracker
This commit is contained in:
parent
e77e40b337
commit
5953841466
10
server.js
10
server.js
@ -61,9 +61,17 @@ function Server (opts) {
|
||||
// start an http tracker unless the user explictly says no
|
||||
if (opts.http !== false) {
|
||||
self.http = http.createServer()
|
||||
self.http.on('request', function (req, res) { self.onHttpRequest(req, res) })
|
||||
self.http.on('error', function (err) { self._onError(err) })
|
||||
self.http.on('listening', onListening)
|
||||
|
||||
// Add default http request handler on next tick to give user the chance to add
|
||||
// their own handler first. Handle requests untouched by user's handler.
|
||||
process.nextTick(function () {
|
||||
self.http.on('request', function (req, res) {
|
||||
if (res.headersSent) return
|
||||
self.onHttpRequest(req, res)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// start a udp tracker unless the user explicitly says no
|
||||
|
Loading…
Reference in New Issue
Block a user