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

Correctly validate the response status for non-HTTP fetch requests (PR 8768 follow-up)
This commit is contained in:
Yury Delendik 2017-09-05 12:47:44 -05:00 committed by GitHub
commit 9b14f8ea2a
2 changed files with 3 additions and 6 deletions

View File

@ -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();
@ -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();

View File

@ -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;
}