Use ranges in preroll to avoid large downloads
This will effectively request the first 2 bytes from a server? Why 2 bytes? Because a lot of servers are broken when bytes=0-0 Related to #70
This commit is contained in:
parent
f04dda308b
commit
ee7f470269
@ -260,6 +260,9 @@ export class Download extends BaseDownload {
|
|||||||
const {signal} = controller;
|
const {signal} = controller;
|
||||||
const res = await fetch(this.uURL.toString(), {
|
const res = await fetch(this.uURL.toString(), {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
headers: new Headers({
|
||||||
|
Range: "bytes=0-1",
|
||||||
|
}),
|
||||||
mode: "same-origin",
|
mode: "same-origin",
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
@ -305,6 +308,9 @@ export class Download extends BaseDownload {
|
|||||||
const {signal} = controller;
|
const {signal} = controller;
|
||||||
const res = await fetch(rurl, {
|
const res = await fetch(rurl, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
headers: new Headers({
|
||||||
|
Range: "bytes=0-1",
|
||||||
|
}),
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
if (res.body) {
|
if (res.body) {
|
||||||
@ -346,7 +352,7 @@ export class Download extends BaseDownload {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
this.error = "SERVER_UNAUTHORIZED";
|
this.error = "SERVER_UNAUTHORIZED";
|
||||||
}
|
}
|
||||||
else if (status === 400 || status === 405) {
|
else if (status === 400 || status === 405 || status === 416) {
|
||||||
PREROLL_NOPE.add(this.uURL.host);
|
PREROLL_NOPE.add(this.uURL.host);
|
||||||
}
|
}
|
||||||
else if (status > 400 && status < 500) {
|
else if (status > 400 && status < 500) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user