From 4b4fcecf7027704fff5c242c39365fdbf57956ab Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 17 Feb 2018 23:19:43 +0100 Subject: [PATCH] Ensure that we only pass in the necessary parameters when initializing `PDFDataTransportStream`/`PDFNetworkStream` in `src/display/api.js` With options being moved from the global `PDFJS` object and into `getDocument`, a side-effect is that we're now passing in a fair number of useless parameters to the various transport/network streams. Even though this doesn't *currently* cause any problems, it nonetheless seem like a good idea to explicitly provide the parameters that are actually necessary. --- src/display/api.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index 781bc7021..163f257b2 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -332,9 +332,22 @@ function getDocument(src) { let networkStream; if (rangeTransport) { - networkStream = new PDFDataTransportStream(params, rangeTransport); + networkStream = new PDFDataTransportStream({ + length: params.length, + initialData: params.initialData, + disableRange: params.disableRange, + disableStream: params.disableStream, + }, rangeTransport); } else if (!params.data) { - networkStream = createPDFNetworkStream(params); + networkStream = createPDFNetworkStream({ + url: params.url, + length: params.length, + httpHeaders: params.httpHeaders, + withCredentials: params.withCredentials, + rangeChunkSize: params.rangeChunkSize, + disableRange: params.disableRange, + disableStream: params.disableStream, + }); } var messageHandler = new MessageHandler(docId, workerId, worker.port); @@ -363,8 +376,6 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { if (worker.destroyed) { return Promise.reject(new Error('Worker was destroyed')); } - let apiVersion = - typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('BUNDLE_VERSION') : null; if (pdfDataRangeTransport) { source.length = pdfDataRangeTransport.length; @@ -372,7 +383,8 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { } return worker.messageHandler.sendWithPromise('GetDocRequest', { docId, - apiVersion, + apiVersion: (typeof PDFJSDev !== 'undefined' ? + PDFJSDev.eval('BUNDLE_VERSION') : null), source: { data: source.data, url: source.url,