Skip to content

Commit 991363a

Browse files
committed
Revert "server _onHttpRequest(): ensure non-empty params"
This reverts commit 74d9139. Conflicts: server.js feross commented on 74d9139 5 hours ago > Do we need to check for empty params here? > > _onRequest should return an error via callback because > params.action is missing. Won't that work? webtorrent@74d9139#commitcomment-8937428
1 parent 66b71db commit 991363a

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

server.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,22 @@ Server.prototype.getSwarm = function (binaryInfoHash) {
127127

128128
Server.prototype._onHttpRequest = function (req, res) {
129129
var self = this
130-
var error
130+
131131
var params
132132
try {
133133
params = parseHttpRequest(req, {
134134
trustProxy: self._trustProxy
135135
})
136136
} catch (err) {
137-
error = err
138-
}
139-
140-
if (!error && !params) error = new Error('Empty HTTP parameters')
141-
if (error) {
142-
debug('sent error %s', error.message)
137+
debug('sent error %s', err.message)
143138
res.end(bencode.encode({
144-
'failure reason': error.message
139+
'failure reason': err.message
145140
}))
146141

147142
// even though it's an error for the client, it's just a warning for the server.
148143
// don't crash the server because a client sent bad data :)
149-
self.emit('warning', error)
150-
144+
self.emit('warning', err)
145+
151146
return
152147
}
153148

0 commit comments

Comments
 (0)