Merge pull request #161 from yciabaud/stats-json-header

Use correct HTTP header to work with JSON on GET
This commit is contained in:
Feross Aboukhadijeh 2016-06-13 16:18:19 -07:00 committed by GitHub
commit f83d2f7966
2 changed files with 2 additions and 3 deletions

View File

@ -196,7 +196,7 @@ function Server (opts) {
peersIPv6: countPeers(isIPv6)
}
if (req.url === '/stats.json' || req.headers['content-type'] === 'application/json') {
if (req.url === '/stats.json' || req.headers['accept'] === 'application/json') {
res.write(JSON.stringify(stats))
res.end()
} else if (req.url === '/stats') {

View File

@ -60,7 +60,7 @@ test('server: get empty stats with json header', function (t) {
var opts = {
url: announceUrl.replace('/announce', '/stats'),
headers: {
'content-type': 'json'
'accept': 'application/json'
},
json: true
}
@ -134,7 +134,6 @@ test('server: get leecher stats.json', function (t) {
get.concat(opts, function (err, res, stats) {
t.error(err)
console.log(stats)
t.equal(res.statusCode, 200)
t.equal(stats.torrents, 1)