Merge pull request #15343 from Snuffleupagus/AbortController-unconditional
Use `AbortController` unconditionally with the Fetch API
This commit is contained in:
commit
a1cc9238b0
@ -35,7 +35,7 @@ function createFetchOptions(headers, withCredentials, abortController) {
|
|||||||
return {
|
return {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers,
|
headers,
|
||||||
signal: abortController?.signal,
|
signal: abortController.signal,
|
||||||
mode: "cors",
|
mode: "cors",
|
||||||
credentials: withCredentials ? "include" : "same-origin",
|
credentials: withCredentials ? "include" : "same-origin",
|
||||||
redirect: "follow",
|
redirect: "follow",
|
||||||
@ -114,9 +114,7 @@ class PDFFetchStreamReader {
|
|||||||
this._disableRange = true;
|
this._disableRange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof AbortController !== "undefined") {
|
this._abortController = new AbortController();
|
||||||
this._abortController = new AbortController();
|
|
||||||
}
|
|
||||||
this._isStreamingSupported = !source.disableStream;
|
this._isStreamingSupported = !source.disableStream;
|
||||||
this._isRangeSupported = !source.disableRange;
|
this._isRangeSupported = !source.disableRange;
|
||||||
|
|
||||||
@ -207,9 +205,7 @@ class PDFFetchStreamReader {
|
|||||||
if (this._reader) {
|
if (this._reader) {
|
||||||
this._reader.cancel(reason);
|
this._reader.cancel(reason);
|
||||||
}
|
}
|
||||||
if (this._abortController) {
|
this._abortController.abort();
|
||||||
this._abortController.abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,10 +220,7 @@ class PDFFetchStreamRangeReader {
|
|||||||
this._readCapability = createPromiseCapability();
|
this._readCapability = createPromiseCapability();
|
||||||
this._isStreamingSupported = !source.disableStream;
|
this._isStreamingSupported = !source.disableStream;
|
||||||
|
|
||||||
if (typeof AbortController !== "undefined") {
|
this._abortController = new AbortController();
|
||||||
this._abortController = new AbortController();
|
|
||||||
}
|
|
||||||
|
|
||||||
this._headers = createHeaders(this._stream.httpHeaders);
|
this._headers = createHeaders(this._stream.httpHeaders);
|
||||||
this._headers.append("Range", `bytes=${begin}-${end - 1}`);
|
this._headers.append("Range", `bytes=${begin}-${end - 1}`);
|
||||||
|
|
||||||
@ -274,9 +267,7 @@ class PDFFetchStreamRangeReader {
|
|||||||
if (this._reader) {
|
if (this._reader) {
|
||||||
this._reader.cancel(reason);
|
this._reader.cancel(reason);
|
||||||
}
|
}
|
||||||
if (this._abortController) {
|
this._abortController.abort();
|
||||||
this._abortController.abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user