Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.js4
-rw-r--r--lib/torrent.js5
-rw-r--r--test/basic-node.js3
3 files changed, 9 insertions, 3 deletions
diff --git a/index.js b/index.js
index 4a62766..0ccc4bb 100644
--- a/index.js
+++ b/index.js
@@ -79,7 +79,9 @@ function WebTorrent (opts) {
debug('new webtorrent (peerId %s, nodeId %s)', self.peerIdHex, self.nodeIdHex)
if (typeof loadIPSet === 'function') {
- loadIPSet(opts.blocklist, function (err, ipSet) {
+ loadIPSet(opts.blocklist, {
+ headers: { 'user-agent': 'WebTorrent (http://webtorrent.io)' }
+ }, function (err, ipSet) {
self.blocked = ipSet
ready()
})
diff --git a/lib/torrent.js b/lib/torrent.js
index db8c33f..e6bd82e 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -79,7 +79,10 @@ function Torrent (torrentId, opts) {
} else if (typeof get === 'function' && /^https?:/.test(torrentId)) {
// http or https url to torrent file
- get(torrentId, function (err, res) {
+ get({
+ url: torrentId,
+ headers: { 'user-agent': 'WebTorrent (http://webtorrent.io)' }
+ }, function (err, res) {
if (err)
return self.emit('error', new Error('error downloading torrent: ' + err.message))
res.pipe(concat(onTorrentId))
diff --git a/test/basic-node.js b/test/basic-node.js
index ad269f0..614bdbe 100644
--- a/test/basic-node.js
+++ b/test/basic-node.js
@@ -13,9 +13,10 @@ var numbersPath = __dirname + '/content/numbers'
var leavesMagnetURI = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=http%3A%2F%2Ftracker.thepiratebay.org%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ffr33domtracker.h33t.com%3A3310%2Fannounce&tr=http%3A%2F%2Ftracker.bittorrent.am%2Fannounce'
test('client.add (http url to a torrent file (string))', function (t) {
- t.plan(2)
+ t.plan(3)
var server = http.createServer(function (req, res) {
+ t.equal(req.headers['user-agent'], 'WebTorrent (http://webtorrent.io)')
res.end(leaves)
})