Merge pull request #15343 from Snuffleupagus/AbortController-unconditional

Use `AbortController` unconditionally with the Fetch API
This commit is contained in:
Tim van der Meij 2022-08-27 13:08:26 +02:00 committed by GitHub
commit a1cc9238b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,7 @@ function createFetchOptions(headers, withCredentials, abortController) {
return {
method: "GET",
headers,
signal: abortController?.signal,
signal: abortController.signal,
mode: "cors",
credentials: withCredentials ? "include" : "same-origin",
redirect: "follow",
@ -114,9 +114,7 @@ class PDFFetchStreamReader {
this._disableRange = true;
}
if (typeof AbortController !== "undefined") {
this._abortController = new AbortController();
}
this._abortController = new AbortController();
this._isStreamingSupported = !source.disableStream;
this._isRangeSupported = !source.disableRange;
@ -207,9 +205,7 @@ class PDFFetchStreamReader {
if (this._reader) {
this._reader.cancel(reason);
}
if (this._abortController) {
this._abortController.abort();
}
this._abortController.abort();
}
}
@ -224,10 +220,7 @@ class PDFFetchStreamRangeReader {
this._readCapability = createPromiseCapability();
this._isStreamingSupported = !source.disableStream;
if (typeof AbortController !== "undefined") {
this._abortController = new AbortController();
}
this._abortController = new AbortController();
this._headers = createHeaders(this._stream.httpHeaders);
this._headers.append("Range", `bytes=${begin}-${end - 1}`);
@ -274,9 +267,7 @@ class PDFFetchStreamRangeReader {
if (this._reader) {
this._reader.cancel(reason);
}
if (this._abortController) {
this._abortController.abort();
}
this._abortController.abort();
}
}