timeout chunk requests after 5 minutes. try to avoid snap with setTimeout

This commit is contained in:
j 2015-03-26 14:25:56 +05:30
parent 1d2675ab97
commit 3d3787b802

View file

@ -174,6 +174,7 @@ pandora.fs = (function() {
xhr.setRequestHeader('Range', 'bytes=' + offset + '-' + end); xhr.setRequestHeader('Range', 'bytes=' + offset + '-' + end);
xhr.withCredentials = true; xhr.withCredentials = true;
xhr.responseType = 'blob'; xhr.responseType = 'blob';
xhr.timeout = 1000 * 60 * 5;
xhr.addEventListener('progress', function(event) { xhr.addEventListener('progress', function(event) {
if (event.lengthComputable) { if (event.lengthComputable) {
if (!total) { if (!total) {
@ -196,7 +197,9 @@ pandora.fs = (function() {
if (offset + blobSize < total) { if (offset + blobSize < total) {
partialDownload(offset + blobSize + 1); partialDownload(offset + blobSize + 1);
} else { } else {
that.storeBlob(new Blob(blobs), name, callback); setTimeout() {
that.storeBlob(new Blob(blobs), name, callback);
});
} }
}); });
xhr.addEventListener('error', function (event) { xhr.addEventListener('error', function (event) {