Skip to content

Commit

Permalink
Avoid using the Fetch API, in GENERIC builds, for unsupported proto…
Browse files Browse the repository at this point in the history
…cols (issue 10587)
  • Loading branch information
Snuffleupagus committed Feb 26, 2019
1 parent 506514b commit 38c2941
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/display/display_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,5 +486,6 @@ export {
DOMSVGFactory,
StatTimer,
DummyStatTimer,
isValidFetchUrl,
loadScript,
};
17 changes: 10 additions & 7 deletions src/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
return new PDFNodeStream(params);
});
} else if (isFetchSupported()) {
let PDFFetchStream = require('./display/fetch_stream.js').PDFFetchStream;
pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
return new PDFFetchStream(params);
});
} else {
let PDFNetworkStream = require('./display/network.js').PDFNetworkStream;
let PDFFetchStream;
if (isFetchSupported()) {
PDFFetchStream = require('./display/fetch_stream.js').PDFFetchStream;
}
pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
if (PDFFetchStream &&
pdfjsDisplayDisplayUtils.isValidFetchUrl(params.url)) {
return new PDFFetchStream(params);
}
return new PDFNetworkStream(params);
});
}
Expand All @@ -70,8 +73,8 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
PDFFetchStream = require('./display/fetch_stream.js').PDFFetchStream;
}
pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
if (PDFFetchStream && /^https?:/i.test(params.url)) {
// "fetch" is only supported for http(s), not file/ftp.
if (PDFFetchStream &&
pdfjsDisplayDisplayUtils.isValidFetchUrl(params.url)) {
return new PDFFetchStream(params);
}
return new PDFNetworkStream(params);
Expand Down

0 comments on commit 38c2941

Please sign in to comment.