Merge pull request #4258 from Rob--W/network-reduce-requests
Do not switch to a range request for small PDFs
This commit is contained in:
commit
522167ffb2
@ -19,6 +19,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
// The maximum number of bytes fetched per range request
|
||||
var RANGE_CHUNK_SIZE = 65536;
|
||||
|
||||
// TODO(mack): Make use of PDFJS.Util.inherit() when it becomes available
|
||||
var BasePdfManager = (function BasePdfManagerClosure() {
|
||||
function BasePdfManager() {
|
||||
@ -132,9 +135,6 @@ var LocalPdfManager = (function LocalPdfManagerClosure() {
|
||||
})();
|
||||
|
||||
var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
||||
|
||||
var CHUNK_SIZE = 65536;
|
||||
|
||||
function NetworkPdfManager(args, msgHandler) {
|
||||
|
||||
this.msgHandler = msgHandler;
|
||||
@ -147,7 +147,7 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
||||
disableAutoFetch: args.disableAutoFetch,
|
||||
initialData: args.initialData
|
||||
};
|
||||
this.streamManager = new ChunkedStreamManager(args.length, CHUNK_SIZE,
|
||||
this.streamManager = new ChunkedStreamManager(args.length, RANGE_CHUNK_SIZE,
|
||||
args.url, params);
|
||||
|
||||
this.pdfModel = new PDFDocument(this, this.streamManager.getStream(),
|
||||
|
@ -18,7 +18,7 @@
|
||||
MissingPDFException, PasswordException, PDFJS, Promise,
|
||||
UnknownErrorException, NetworkManager, LocalPdfManager,
|
||||
NetworkPdfManager, XRefParseException, LegacyPromise,
|
||||
isInt, PasswordResponses, MessageHandler, Ref */
|
||||
isInt, PasswordResponses, MessageHandler, Ref, RANGE_CHUNK_SIZE */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -119,6 +119,13 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
if (!isInt(length)) {
|
||||
return;
|
||||
}
|
||||
source.length = length;
|
||||
if (length <= 2 * RANGE_CHUNK_SIZE) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
// NOTE: by cancelling the full request, and then issuing range
|
||||
// requests, there will be an issue for sites where you can only
|
||||
@ -126,7 +133,6 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
// server should not be returning that it can support range requests.
|
||||
networkManager.abortRequest(fullRequestXhrId);
|
||||
|
||||
source.length = length;
|
||||
try {
|
||||
pdfManager = new NetworkPdfManager(source, handler);
|
||||
pdfManagerPromise.resolve(pdfManager);
|
||||
|
Loading…
x
Reference in New Issue
Block a user