diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2014-04-23 14:31:25 +0400 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2014-04-23 14:31:25 +0400 |
commit | 6873784f59df81cacd0895a987a17d08dad809b3 (patch) | |
tree | cbe8eb7e7f1890c8dfbe0dd091427269303b1faa /index.js | |
parent | 5d4ec711b6acea400be3dfca1c9b6860bf4329bf (diff) |
don't 404 if server is not ready, just wait
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -90,6 +90,11 @@ WebTorrent.prototype._onReady = function () { WebTorrent.prototype._onRequest = function (req, res) { var self = this + + if (!self._ready) { + return self.once('ready', self._onRequest.bind(self, req, res)) + } + var u = url.parse(req.url) if (u.pathname === '/favicon.ico') { @@ -101,7 +106,7 @@ WebTorrent.prototype._onRequest = function (req, res) { var i = Number(u.pathname.slice(1)) - if (isNaN(i) || i >= e.files.length || !self._ready) { + if (isNaN(i) || i >= e.files.length) { res.statusCode = 404 return res.end() } |