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:
		
						commit
						9b14f8ea2a
					
				@ -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();
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user