mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Address the final round of review comments for Content-Disposition filename extraction
This patch updates the `IPDFStreamReader` interface and ensures that the interface/implementation of `network.js`, `fetch_stream.js`, `node_stream.js`, and `transport_stream.js` all match properly. The unit-tests are also adjusted, to more closely replicate the actual behaviour of the various actual `IPDFStreamReader` implementations. Finally, this patch adjusts the use of the Content-Disposition filename when setting the title in the viewer, and adds `PDFDocumentProperties` support as well.
This commit is contained in:
parent
eb1f6f4c24
commit
69a8336cf1
12 changed files with 151 additions and 121 deletions
|
@ -341,7 +341,7 @@ function PDFNetworkStreamFullRequestReader(manager, source) {
|
|||
this._requests = [];
|
||||
this._done = false;
|
||||
this._storedError = undefined;
|
||||
this._fileName = null;
|
||||
this._filename = null;
|
||||
|
||||
this.onProgress = null;
|
||||
}
|
||||
|
@ -371,6 +371,8 @@ PDFNetworkStreamFullRequestReader.prototype = {
|
|||
this._isRangeSupported = true;
|
||||
}
|
||||
|
||||
this._filename = extractFilenameFromHeader(getResponseHeader);
|
||||
|
||||
var networkManager = this._manager;
|
||||
if (networkManager.isStreamingRequest(fullRequestXhrId)) {
|
||||
// We can continue fetching when progressive loading is enabled,
|
||||
|
@ -385,11 +387,6 @@ PDFNetworkStreamFullRequestReader.prototype = {
|
|||
networkManager.abortRequest(fullRequestXhrId);
|
||||
}
|
||||
|
||||
// Content-Disposition: attachment; filename=Naïve file.txt
|
||||
if (networkManager.isPendingRequest(fullRequestXhrId)) {
|
||||
this._fileName = extractFilenameFromHeader(getResponseHeader);
|
||||
}
|
||||
|
||||
this._headersReceivedCapability.resolve();
|
||||
},
|
||||
|
||||
|
@ -438,8 +435,8 @@ PDFNetworkStreamFullRequestReader.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
get fileName() {
|
||||
return this._fileName;
|
||||
get filename() {
|
||||
return this._filename;
|
||||
},
|
||||
|
||||
get isRangeSupported() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue