Merge pull request #9465 from Snuffleupagus/streams-unify-disableRange-contentLength

Attempt to unify the `disableRange`/`contentLength` handling in the various network streams
This commit is contained in:
Tim van der Meij 2018-02-11 16:21:34 +01:00 committed by GitHub
commit b3557483cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 13 deletions

View File

@ -74,14 +74,14 @@ class PDFFetchStreamReader {
this._withCredentials = source.withCredentials;
this._contentLength = source.length;
this._headersCapability = createPromiseCapability();
this._disableRange = source.disableRange;
this._disableRange = source.disableRange || false;
this._rangeChunkSize = source.rangeChunkSize;
if (!this._rangeChunkSize && !this._disableRange) {
this._disableRange = true;
}
this._isRangeSupported = !source.disableRange;
this._isStreamingSupported = !source.disableStream;
this._isRangeSupported = !source.disableRange;
this._headers = new Headers();
for (let property in this._stream.httpHeaders) {
@ -112,8 +112,9 @@ class PDFFetchStreamReader {
disableRange: this._disableRange,
});
this._contentLength = suggestedLength;
this._isRangeSupported = allowRangeRequests;
// Setting right content length.
this._contentLength = suggestedLength || this._contentLength;
this._filename = extractFilenameFromHeader(getResponseHeader);

View File

@ -355,7 +355,6 @@ PDFNetworkStreamFullRequestReader.prototype = {
const getResponseHeader = (name) => {
return fullRequestXhr.getResponseHeader(name);
};
let { allowRangeRequests, suggestedLength, } =
validateRangeRequestCapabilities({
getResponseHeader,
@ -364,12 +363,11 @@ PDFNetworkStreamFullRequestReader.prototype = {
disableRange: this._disableRange,
});
// Setting right content length.
this._contentLength = suggestedLength || this._contentLength;
if (allowRangeRequests) {
this._isRangeSupported = true;
}
// Setting right content length.
this._contentLength = suggestedLength || this._contentLength;
this._filename = extractFilenameFromHeader(getResponseHeader);

View File

@ -304,11 +304,9 @@ class PDFNodeStreamFullReader extends BaseFullReader {
disableRange: this._disableRange,
});
if (allowRangeRequests) {
this._isRangeSupported = true;
}
this._isRangeSupported = allowRangeRequests;
// Setting right content length.
this._contentLength = suggestedLength;
this._contentLength = suggestedLength || this._contentLength;
this._filename = extractFilenameFromHeader(getResponseHeader);
};

View File

@ -28,8 +28,8 @@ var PDFDataTransportStream = (function PDFDataTransportStreamClosure() {
}
this._pdfDataRangeTransport = pdfDataRangeTransport;
this._isRangeSupported = !(params.disableRange);
this._isStreamingSupported = !(params.disableStream);
this._isStreamingSupported = !params.disableStream;
this._isRangeSupported = !params.disableRange;
this._contentLength = params.length;
this._fullRequestReader = null;