Skip to content

Commit

Permalink
Merge pull request #8866 from Snuffleupagus/fix-non-HTTP-validateResp…
Browse files Browse the repository at this point in the history
…onseStatus

Correctly validate the response status for non-HTTP fetch requests (PR 8768 follow-up)
  • Loading branch information
yurydelendik authored Sep 5, 2017
2 parents 4edd4fb + 41415ba commit 9b14f8e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/display/fetch_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class PDFFetchStreamReader {
let url = this._stream.source.url;
fetch(url, createFetchOptions(this._headers, this._withCredentials)).
then((response) => {
if (!validateResponseStatus(response.status, this._stream.isHttp)) {
if (!validateResponseStatus(response.status)) {
throw createResponseStatusError(response.status, url);
}
this._reader = response.body.getReader();
Expand Down Expand Up @@ -188,7 +188,7 @@ class PDFFetchStreamRangeReader {
let url = this._stream.source.url;
fetch(url, createFetchOptions(this._headers, this._withCredentials)).
then((response) => {
if (!validateResponseStatus(response.status, this._stream.isHttp)) {
if (!validateResponseStatus(response.status)) {
throw createResponseStatusError(response.status, url);
}
this._readCapability.resolve();
Expand Down
5 changes: 1 addition & 4 deletions src/display/network_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ function createResponseStatusError(status, url) {
') while retrieving PDF "' + url + '".', status);
}

function validateResponseStatus(status, isHttp) {
if (!isHttp) {
return status === 0;
}
function validateResponseStatus(status) {
return status === 200 || status === 206;
}

Expand Down

0 comments on commit 9b14f8e

Please sign in to comment.