mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
set returnValues.suggestedLength to Content-Length if integer
This commit is contained in:
parent
ff2df9c5b6
commit
4cf10ac79d
2 changed files with 48 additions and 22 deletions
|
@ -27,6 +27,20 @@ function validateRangeRequestCapabilities({ getResponseHeader, isHttp,
|
|||
allowRangeRequests: false,
|
||||
suggestedLength: undefined,
|
||||
};
|
||||
|
||||
let length = parseInt(getResponseHeader('Content-Length'), 10);
|
||||
if (!Number.isInteger(length)) {
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
returnValues.suggestedLength = length;
|
||||
|
||||
if (length <= 2 * rangeChunkSize) {
|
||||
// The file size is smaller than the size of two chunks, so it does not
|
||||
// make any sense to abort the request and retry with a range request.
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
if (disableRange || !isHttp) {
|
||||
return returnValues;
|
||||
}
|
||||
|
@ -39,18 +53,6 @@ function validateRangeRequestCapabilities({ getResponseHeader, isHttp,
|
|||
return returnValues;
|
||||
}
|
||||
|
||||
let length = parseInt(getResponseHeader('Content-Length'), 10);
|
||||
if (!Number.isInteger(length)) {
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
returnValues.suggestedLength = length;
|
||||
if (length <= 2 * rangeChunkSize) {
|
||||
// The file size is smaller than the size of two chunks, so it does not
|
||||
// make any sense to abort the request and retry with a range request.
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
returnValues.allowRangeRequests = true;
|
||||
return returnValues;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue