Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows customization of webseed http requests through an options call… #1613

Open
wants to merge 2 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -72,6 +72,7 @@ class Torrent extends EventEmitter {
this.skipVerify = !!opts.skipVerify
this._store = opts.store || FSChunkStore
this._getAnnounceOpts = opts.getAnnounceOpts
this._getWebseedOpts = opts.getWebseedOpts

this.strategy = opts.strategy || 'sequential'

@@ -110,14 +110,17 @@ class WebConn extends Wire {
'Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d',
url, pieceIndex, offset, length, start, end
)
const opts = {
let opts = {
url,
method: 'GET',
headers: {
'user-agent': `WebTorrent/${VERSION} (https://webtorrent.io)`,
range: `bytes=${start}-${end}`
}
}
if (this._torrent._getWebseedOpts) {
opts = this._torrent._getWebseedOpts(opts)
}
function onResponse (res, data) {
if (res.statusCode < 200 || res.statusCode >= 300) {
hasError = true
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.