mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 03:16:24 +00:00
Merge pull request #161 from yciabaud/stats-json-header
Use correct HTTP header to work with JSON on GET
This commit is contained in:
commit
f83d2f7966
@ -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') {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user