Skip to content

Commit

Permalink
Adds tests for node_stream
Browse files Browse the repository at this point in the history
  • Loading branch information
mukulmishra18 committed Aug 18, 2017
1 parent b148a29 commit 0ce321b
Show file tree
Hide file tree
Showing 6 changed files with 352 additions and 162 deletions.
15 changes: 6 additions & 9 deletions src/display/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,16 @@ function PDFNetworkStreamFullRequestReader(manager, options) {
}

PDFNetworkStreamFullRequestReader.prototype = {
getResponseHeader(name) {
let fullRequestXhrId = this._fullRequestId;
let fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);

return fullRequestXhr.getResponseHeader(name);
},

_onHeadersReceived:
function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
var fullRequestXhrId = this._fullRequestId;
var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);

let { allowRangeRequests, suggestedLength, } =
validateRangeRequestCapabilities({
getResponseHeader: this.getResponseHeader.bind(this),
getResponseHeader: (name) => {
return fullRequestXhr.getResponseHeader(name);
},
isHttp: this._manager.isHttp,
rangeChunkSize: this._rangeChunkSize,
disableRange: this._disableRange,
Expand All @@ -376,7 +374,6 @@ PDFNetworkStreamFullRequestReader.prototype = {
}

var networkManager = this._manager;
var fullRequestXhrId = this._fullRequestId;
if (networkManager.isStreamingRequest(fullRequestXhrId)) {
// We can continue fetching when progressive loading is enabled,
// and we don't need the autoFetch feature.
Expand Down
3 changes: 2 additions & 1 deletion src/display/network_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
* limitations under the License.
*/

import { isInt } from '../shared/util';
import { assert, isInt } from '../shared/util';

function validateRangeRequestCapabilities({ getResponseHeader, isHttp,
rangeChunkSize, disableRange, }) {
assert(rangeChunkSize > 0);
let returnValues = {
allowRangeRequests: false,
suggestedLength: undefined,
Expand Down
Loading

0 comments on commit 0ce321b

Please sign in to comment.