Browse Source

Merge pull request #8866 from Snuffleupagus/fix-non-HTTP-validateResponseStatus

Correctly validate the response status for non-HTTP fetch requests (PR 8768 follow-up)
Yury Delendik 8 years ago committed by GitHub
parent
commit
9b14f8ea2a
  1. 4
      src/display/fetch_stream.js
  2. 5
      src/display/network_utils.js

4
src/display/fetch_stream.js

@ -94,7 +94,7 @@ class PDFFetchStreamReader {
let url = this._stream.source.url; let url = this._stream.source.url;
fetch(url, createFetchOptions(this._headers, this._withCredentials)). fetch(url, createFetchOptions(this._headers, this._withCredentials)).
then((response) => { then((response) => {
if (!validateResponseStatus(response.status, this._stream.isHttp)) { if (!validateResponseStatus(response.status)) {
throw createResponseStatusError(response.status, url); throw createResponseStatusError(response.status, url);
} }
this._reader = response.body.getReader(); this._reader = response.body.getReader();
@ -188,7 +188,7 @@ class PDFFetchStreamRangeReader {
let url = this._stream.source.url; let url = this._stream.source.url;
fetch(url, createFetchOptions(this._headers, this._withCredentials)). fetch(url, createFetchOptions(this._headers, this._withCredentials)).
then((response) => { then((response) => {
if (!validateResponseStatus(response.status, this._stream.isHttp)) { if (!validateResponseStatus(response.status)) {
throw createResponseStatusError(response.status, url); throw createResponseStatusError(response.status, url);
} }
this._readCapability.resolve(); this._readCapability.resolve();

5
src/display/network_utils.js

@ -61,10 +61,7 @@ function createResponseStatusError(status, url) {
') while retrieving PDF "' + url + '".', status); ') while retrieving PDF "' + url + '".', status);
} }
function validateResponseStatus(status, isHttp) { function validateResponseStatus(status) {
if (!isHttp) {
return status === 0;
}
return status === 200 || status === 206; return status === 200 || status === 206;
} }

Loading…
Cancel
Save