Clamp end of range request to be the length of the file

This commit is contained in:
Mack Duan 2013-04-19 16:27:39 -07:00
parent 49ff029f5f
commit fdd092bb92

View File

@ -258,7 +258,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
for (var i = 0, n = groupedChunks.length; i < n; ++i) {
var groupedChunk = groupedChunks[i];
var begin = groupedChunk.beginChunk * this.chunkSize;
var end = groupedChunk.endChunk * this.chunkSize;
var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
this.sendRequest(begin, end);
}
@ -314,7 +314,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
for (var i = 0; i < groupedChunksToRequest.length; ++i) {
var groupedChunk = groupedChunksToRequest[i];
var begin = groupedChunk.beginChunk * this.chunkSize;
var end = groupedChunk.endChunk * this.chunkSize;
var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
this.sendRequest(begin, end);
}
},