Skip to content

Commit

Permalink
Merge pull request mozilla#9465 from Snuffleupagus/streams-unify-disa…
Browse files Browse the repository at this point in the history
…bleRange-contentLength

Attempt to unify the `disableRange`/`contentLength` handling in the various network streams
  • Loading branch information
timvandermeij committed Feb 11, 2018
2 parents 368a91b + ad06979 commit b355748
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/display/fetch_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 2 additions & 4 deletions src/display/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ PDFNetworkStreamFullRequestReader.prototype = {
const getResponseHeader = (name) => {
return fullRequestXhr.getResponseHeader(name);
};

let { allowRangeRequests, suggestedLength, } =
validateRangeRequestCapabilities({
getResponseHeader,
Expand All @@ -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);

Expand Down
6 changes: 2 additions & 4 deletions src/display/node_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
4 changes: 2 additions & 2 deletions src/display/transport_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b355748

Please sign in to comment.