mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 10:31:36 +00:00
server _onHttpRequest(): ensure non-empty params
This commit is contained in:
parent
e64fecc063
commit
74d9139049
13
server.js
13
server.js
@ -127,21 +127,26 @@ Server.prototype.getSwarm = function (binaryInfoHash) {
|
|||||||
|
|
||||||
Server.prototype._onHttpRequest = function (req, res) {
|
Server.prototype._onHttpRequest = function (req, res) {
|
||||||
var self = this
|
var self = this
|
||||||
|
var error
|
||||||
var params
|
var params
|
||||||
try {
|
try {
|
||||||
params = parseHttpRequest(req, {
|
params = parseHttpRequest(req, {
|
||||||
trustProxy: self._trustProxy
|
trustProxy: self._trustProxy
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debug('sent error %s', err.message)
|
error = err
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!error && !params) error = new Error('Empty HTTP parameters')
|
||||||
|
if (error) {
|
||||||
|
debug('sent error %s', error.message)
|
||||||
res.end(bencode.encode({
|
res.end(bencode.encode({
|
||||||
'failure reason': err.message
|
'failure reason': error.message
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// even though it's an error for the client, it's just a warning for the server.
|
// even though it's an error for the client, it's just a warning for the server.
|
||||||
// don't crash the server because a client sent bad data :)
|
// don't crash the server because a client sent bad data :)
|
||||||
self.emit('warning', err)
|
self.emit('warning', error)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user