mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Avoid using the Fetch API, in GENERIC
builds, for unsupported protocols (issue 10587)
This commit is contained in:
parent
cbc07f985b
commit
f664e074c9
3 changed files with 36 additions and 8 deletions
|
@ -490,5 +490,6 @@ export {
|
|||
StatTimer,
|
||||
DummyStatTimer,
|
||||
isFetchSupported,
|
||||
isValidFetchUrl,
|
||||
loadScript,
|
||||
};
|
||||
|
|
17
src/pdf.js
17
src/pdf.js
|
@ -37,14 +37,17 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
|||
pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
|
||||
return new PDFNodeStream(params);
|
||||
});
|
||||
} else if (pdfjsDisplayDisplayUtils.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 (pdfjsDisplayDisplayUtils.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);
|
||||
});
|
||||
}
|
||||
|
@ -69,8 +72,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue