if(isNaN(loadDiff)||!isFinite(loadDiff)||loadDiff<0)return;//just in case
}catch(e){
totLoaded+=loadDiff;
ie11workaround=true;
prevLoaded=event.loaded;
}
}.bind(this);
if(ie11workaround){
xhr[i].upload.onload=function(){
//IE11 workarond: xhr.upload does not work properly, therefore we send a bunch of small 256k requests and use the onload event as progress. This is not precise, especially on fast connections
//this stream sent all 20mb of garbage data, start again
xhr[i].onload=function(){
testStream(i,0);
totLoaded+=262144;
}.bind(this);
testStream(i,0);
xhr[i].upload.onerror=function(){
}
//error, abort
xhr[i].onerror=function(){
failed=true;
//error, abort
try{xhr[i].abort();}catch(e){}
failed=true;
delete(xhr[i]);
try{xhr[i].abort();}catch(e){}
}.bind(this);
delete(xhr[i]);
//send xhr
}
xhr[i].open("POST",settings.url_ul+"?r="+Math.random(),true);//random string to prevent caching
xhr[i].open("POST",settings.url_ul+"?r="+Math.random(),true);//random string to prevent caching
xhr[i].setRequestHeader('Content-Encoding','identity');//disable compression (some browsers may refuse it, but data is incompressible anyway)
xhr[i].setRequestHeader('Content-Encoding','identity');//disable compression (some browsers may refuse it, but data is incompressible anyway)
xhr[i].send(req);
xhr[i].send(reqsmall);
}else{
//REGULAR version, no workaround
xhr[i].upload.onprogress=function(event){
if(testStatus!=3){try{x.abort();}catch(e){}}//just in case this XHR is still running after the upload test
//progress event, add number of new loaded bytes to totLoaded