Skip to content

Commit f83d2f7

Browse files
authored
Merge pull request webtorrent#161 from yciabaud/stats-json-header
Use correct HTTP header to work with JSON on GET
2 parents 92a0710 + 29fcf30 commit f83d2f7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function Server (opts) {
196196
peersIPv6: countPeers(isIPv6)
197197
}
198198

199-
if (req.url === '/stats.json' || req.headers['content-type'] === 'application/json') {
199+
if (req.url === '/stats.json' || req.headers['accept'] === 'application/json') {
200200
res.write(JSON.stringify(stats))
201201
res.end()
202202
} else if (req.url === '/stats') {

test/stats.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ test('server: get empty stats with json header', function (t) {
6060
var opts = {
6161
url: announceUrl.replace('/announce', '/stats'),
6262
headers: {
63-
'content-type': 'json'
63+
'accept': 'application/json'
6464
},
6565
json: true
6666
}
@@ -134,7 +134,6 @@ test('server: get leecher stats.json', function (t) {
134134

135135
get.concat(opts, function (err, res, stats) {
136136
t.error(err)
137-
console.log(stats)
138137

139138
t.equal(res.statusCode, 200)
140139
t.equal(stats.torrents, 1)

0 commit comments

Comments
 (0)