allow override of content type to affect headers
authorAlan Knowles <alan@roojs.com>
Fri, 29 Nov 2019 08:23:12 +0000 (16:23 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 29 Nov 2019 08:23:12 +0000 (16:23 +0800)
Roo/data/Connection.js
roojs-all.js
roojs-core-debug.js
roojs-core.js
roojs-debug.js

index 7368844..cf3a67f 100644 (file)
@@ -203,7 +203,9 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, {
                 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
                 p = '';
             }
+            Roo.lib.Ajax.useDefaultHeader == typeof(o.headers['Content-Type']) == 'undefined';
             this.transId = Roo.lib.Ajax.request(method, url, cb, p, o);
+            Roo.lib.Ajax.useDefaultHeader == true;
             return this.transId;
         }else{
             Roo.callback(o.callback, o.scope, [o, null, null]);
index 2423089..4767dbe 100644 (file)
@@ -477,16 +477,17 @@ if(typeof p=="function"){p=p.call(o.scope||window,o);}if(typeof p=="object"){p=R
 }if(o.form){var C=Roo.getDom(o.form);B=B||C.action;var D=C.getAttribute("enctype");if(o.formData){return this.doFormDataUpload(o,p,B);}if(o.isUpload||(D&&D.toLowerCase()=='multipart/form-data')){return this.doFormUpload(o,p,B);}var f=Roo.lib.Ajax.serializeForm(C);
 p=p?(p+'&'+f):f;}var hs=o.headers;if(this.defaultHeaders){hs=Roo.apply(hs||{},this.defaultHeaders);if(!o.headers){o.headers=hs;}}var cb={success:this.handleResponse,failure:this.handleFailure,scope:this,argument:{options:o},timeout:o.timeout||this.timeout}
 ;var E=o.method||this.method||(p?"POST":"GET");if(E=='GET'&&(this.disableCaching&&o.disableCaching!==false)||o.disableCaching===true){B+=(B.indexOf('?')!=-1?'&':'?')+'_dc='+(new Date().getTime());}if(typeof o.autoAbort=='boolean'){if(o.autoAbort){this.abort();
-}}else if(this.autoAbort!==false){this.abort();}if((E=='GET'&&p)||o.xmlData){B+=(B.indexOf('?')!=-1?'&':'?')+p;p='';}this.transId=Roo.lib.Ajax.request(E,B,cb,p,o);return this.transId;}else{Roo.callback(o.callback,o.scope,[o,null,null]);return null;}},isLoading:function(A){if(A){return Roo.lib.Ajax.isCallInProgress(A);
-}else{return this.transId?true:false;}},abort:function(A){if(A||this.isLoading()){Roo.lib.Ajax.abort(A||this.transId);}},handleResponse:function(A){this.transId=false;var B=A.argument.options;A.argument=B?B.argument:null;this.fireEvent("requestcomplete",this,A,B);
-Roo.callback(B.success,B.scope,[A,B]);Roo.callback(B.callback,B.scope,[B,true,A]);},handleFailure:function(A,e){this.transId=false;var B=A.argument.options;A.argument=B?B.argument:null;this.fireEvent("requestexception",this,A,B,e);Roo.callback(B.failure,B.scope,[A,B]);
-Roo.callback(B.callback,B.scope,[B,false,A]);},doFormUpload:function(o,ps,A){var id=Roo.id();var B=document.createElement('iframe');B.id=id;B.name=id;B.className='x-hidden';if(Roo.isIE){B.src=Roo.SSL_SECURE_URL;}document.body.appendChild(B);if(Roo.isIE){document.frames[id].name=id;
-}var C=Roo.getDom(o.form);C.target=id;C.method='POST';C.enctype=C.encoding='multipart/form-data';if(A){C.action=A;}var D,hd;if(ps){D=[];ps=Roo.urlDecode(ps,false);for(var k in ps){if(ps.hasOwnProperty(k)){hd=document.createElement('input');hd.type='hidden';
-hd.name=k;hd.value=ps[k];C.appendChild(hd);D.push(hd);}}}function cb(){var r={responseText:'',responseXML:null};r.argument=o?o.argument:null;try{var F;if(Roo.isIE){F=B.contentWindow.document;}else{F=(B.contentDocument||window.frames[id].document);}if(F&&F.body){r.responseText=F.body.innerHTML;
-}if(F&&F.XMLDocument){r.responseXML=F.XMLDocument;}else{r.responseXML=F;}}catch(e){}Roo.EventManager.removeListener(B,'load',cb,this);this.fireEvent("requestcomplete",this,r,o);Roo.callback(o.success,o.scope,[r,o]);Roo.callback(o.callback,o.scope,[o,true,r]);
-setTimeout(function(){document.body.removeChild(B);},100);}Roo.EventManager.on(B,'load',cb,this);C.submit();if(D){for(var i=0,E=D.length;i<E;i++){C.removeChild(D[i]);}}},doFormDataUpload:function(o,ps,A){var B=Roo.getDom(o.form);B.enctype=B.encoding='multipart/form-data';
-var C=o.formData===true?new FormData(B):o.formData;var cb={success:this.handleResponse,failure:this.handleFailure,scope:this,argument:{options:o},timeout:o.timeout||this.timeout};if(typeof o.autoAbort=='boolean'){if(o.autoAbort){this.abort();}}else if(this.autoAbort!==false){this.abort();
-}Roo.lib.Ajax.useDefaultHeader=false;this.transId=Roo.lib.Ajax.request("POST",A,cb,o.formData,o);Roo.lib.Ajax.useDefaultHeader=true;}});
+}}else if(this.autoAbort!==false){this.abort();}if((E=='GET'&&p)||o.xmlData){B+=(B.indexOf('?')!=-1?'&':'?')+p;p='';}Roo.lib.Ajax.useDefaultHeader==typeof(o.headers['Content-Type'])=='undefined';this.transId=Roo.lib.Ajax.request(E,B,cb,p,o);Roo.lib.Ajax.useDefaultHeader==true;
+return this.transId;}else{Roo.callback(o.callback,o.scope,[o,null,null]);return null;}},isLoading:function(A){if(A){return Roo.lib.Ajax.isCallInProgress(A);}else{return this.transId?true:false;}},abort:function(A){if(A||this.isLoading()){Roo.lib.Ajax.abort(A||this.transId);
+}},handleResponse:function(A){this.transId=false;var B=A.argument.options;A.argument=B?B.argument:null;this.fireEvent("requestcomplete",this,A,B);Roo.callback(B.success,B.scope,[A,B]);Roo.callback(B.callback,B.scope,[B,true,A]);},handleFailure:function(A,e){this.transId=false;
+var B=A.argument.options;A.argument=B?B.argument:null;this.fireEvent("requestexception",this,A,B,e);Roo.callback(B.failure,B.scope,[A,B]);Roo.callback(B.callback,B.scope,[B,false,A]);},doFormUpload:function(o,ps,A){var id=Roo.id();var B=document.createElement('iframe');
+B.id=id;B.name=id;B.className='x-hidden';if(Roo.isIE){B.src=Roo.SSL_SECURE_URL;}document.body.appendChild(B);if(Roo.isIE){document.frames[id].name=id;}var C=Roo.getDom(o.form);C.target=id;C.method='POST';C.enctype=C.encoding='multipart/form-data';if(A){C.action=A;
+}var D,hd;if(ps){D=[];ps=Roo.urlDecode(ps,false);for(var k in ps){if(ps.hasOwnProperty(k)){hd=document.createElement('input');hd.type='hidden';hd.name=k;hd.value=ps[k];C.appendChild(hd);D.push(hd);}}}function cb(){var r={responseText:'',responseXML:null};
+r.argument=o?o.argument:null;try{var F;if(Roo.isIE){F=B.contentWindow.document;}else{F=(B.contentDocument||window.frames[id].document);}if(F&&F.body){r.responseText=F.body.innerHTML;}if(F&&F.XMLDocument){r.responseXML=F.XMLDocument;}else{r.responseXML=F;}
+}catch(e){}Roo.EventManager.removeListener(B,'load',cb,this);this.fireEvent("requestcomplete",this,r,o);Roo.callback(o.success,o.scope,[r,o]);Roo.callback(o.callback,o.scope,[o,true,r]);setTimeout(function(){document.body.removeChild(B);},100);}Roo.EventManager.on(B,'load',cb,this);
+C.submit();if(D){for(var i=0,E=D.length;i<E;i++){C.removeChild(D[i]);}}},doFormDataUpload:function(o,ps,A){var B=Roo.getDom(o.form);B.enctype=B.encoding='multipart/form-data';var C=o.formData===true?new FormData(B):o.formData;var cb={success:this.handleResponse,failure:this.handleFailure,scope:this,argument:{options:o}
+,timeout:o.timeout||this.timeout};if(typeof o.autoAbort=='boolean'){if(o.autoAbort){this.abort();}}else if(this.autoAbort!==false){this.abort();}Roo.lib.Ajax.useDefaultHeader=false;this.transId=Roo.lib.Ajax.request("POST",A,cb,o.formData,o);Roo.lib.Ajax.useDefaultHeader=true;
+}});
 // Roo/Ajax.js
 Roo.Ajax=new Roo.data.Connection({autoAbort:false,serializeForm:function(A){return Roo.lib.Ajax.serializeForm(A);}});
 // Roo/UpdateManager.js
index 1b155c5..240f9be 100644 (file)
@@ -11659,7 +11659,9 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, {
                 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
                 p = '';
             }
+            Roo.lib.Ajax.useDefaultHeader == typeof(o.headers['Content-Type']) == 'undefined';
             this.transId = Roo.lib.Ajax.request(method, url, cb, p, o);
+            Roo.lib.Ajax.useDefaultHeader == true;
             return this.transId;
         }else{
             Roo.callback(o.callback, o.scope, [o, null, null]);
index 0948a1a..7230b3c 100644 (file)
@@ -477,16 +477,17 @@ if(typeof p=="function"){p=p.call(o.scope||window,o);}if(typeof p=="object"){p=R
 }if(o.form){var C=Roo.getDom(o.form);B=B||C.action;var D=C.getAttribute("enctype");if(o.formData){return this.doFormDataUpload(o,p,B);}if(o.isUpload||(D&&D.toLowerCase()=='multipart/form-data')){return this.doFormUpload(o,p,B);}var f=Roo.lib.Ajax.serializeForm(C);
 p=p?(p+'&'+f):f;}var hs=o.headers;if(this.defaultHeaders){hs=Roo.apply(hs||{},this.defaultHeaders);if(!o.headers){o.headers=hs;}}var cb={success:this.handleResponse,failure:this.handleFailure,scope:this,argument:{options:o},timeout:o.timeout||this.timeout}
 ;var E=o.method||this.method||(p?"POST":"GET");if(E=='GET'&&(this.disableCaching&&o.disableCaching!==false)||o.disableCaching===true){B+=(B.indexOf('?')!=-1?'&':'?')+'_dc='+(new Date().getTime());}if(typeof o.autoAbort=='boolean'){if(o.autoAbort){this.abort();
-}}else if(this.autoAbort!==false){this.abort();}if((E=='GET'&&p)||o.xmlData){B+=(B.indexOf('?')!=-1?'&':'?')+p;p='';}this.transId=Roo.lib.Ajax.request(E,B,cb,p,o);return this.transId;}else{Roo.callback(o.callback,o.scope,[o,null,null]);return null;}},isLoading:function(A){if(A){return Roo.lib.Ajax.isCallInProgress(A);
-}else{return this.transId?true:false;}},abort:function(A){if(A||this.isLoading()){Roo.lib.Ajax.abort(A||this.transId);}},handleResponse:function(A){this.transId=false;var B=A.argument.options;A.argument=B?B.argument:null;this.fireEvent("requestcomplete",this,A,B);
-Roo.callback(B.success,B.scope,[A,B]);Roo.callback(B.callback,B.scope,[B,true,A]);},handleFailure:function(A,e){this.transId=false;var B=A.argument.options;A.argument=B?B.argument:null;this.fireEvent("requestexception",this,A,B,e);Roo.callback(B.failure,B.scope,[A,B]);
-Roo.callback(B.callback,B.scope,[B,false,A]);},doFormUpload:function(o,ps,A){var id=Roo.id();var B=document.createElement('iframe');B.id=id;B.name=id;B.className='x-hidden';if(Roo.isIE){B.src=Roo.SSL_SECURE_URL;}document.body.appendChild(B);if(Roo.isIE){document.frames[id].name=id;
-}var C=Roo.getDom(o.form);C.target=id;C.method='POST';C.enctype=C.encoding='multipart/form-data';if(A){C.action=A;}var D,hd;if(ps){D=[];ps=Roo.urlDecode(ps,false);for(var k in ps){if(ps.hasOwnProperty(k)){hd=document.createElement('input');hd.type='hidden';
-hd.name=k;hd.value=ps[k];C.appendChild(hd);D.push(hd);}}}function cb(){var r={responseText:'',responseXML:null};r.argument=o?o.argument:null;try{var F;if(Roo.isIE){F=B.contentWindow.document;}else{F=(B.contentDocument||window.frames[id].document);}if(F&&F.body){r.responseText=F.body.innerHTML;
-}if(F&&F.XMLDocument){r.responseXML=F.XMLDocument;}else{r.responseXML=F;}}catch(e){}Roo.EventManager.removeListener(B,'load',cb,this);this.fireEvent("requestcomplete",this,r,o);Roo.callback(o.success,o.scope,[r,o]);Roo.callback(o.callback,o.scope,[o,true,r]);
-setTimeout(function(){document.body.removeChild(B);},100);}Roo.EventManager.on(B,'load',cb,this);C.submit();if(D){for(var i=0,E=D.length;i<E;i++){C.removeChild(D[i]);}}},doFormDataUpload:function(o,ps,A){var B=Roo.getDom(o.form);B.enctype=B.encoding='multipart/form-data';
-var C=o.formData===true?new FormData(B):o.formData;var cb={success:this.handleResponse,failure:this.handleFailure,scope:this,argument:{options:o},timeout:o.timeout||this.timeout};if(typeof o.autoAbort=='boolean'){if(o.autoAbort){this.abort();}}else if(this.autoAbort!==false){this.abort();
-}Roo.lib.Ajax.useDefaultHeader=false;this.transId=Roo.lib.Ajax.request("POST",A,cb,o.formData,o);Roo.lib.Ajax.useDefaultHeader=true;}});
+}}else if(this.autoAbort!==false){this.abort();}if((E=='GET'&&p)||o.xmlData){B+=(B.indexOf('?')!=-1?'&':'?')+p;p='';}Roo.lib.Ajax.useDefaultHeader==typeof(o.headers['Content-Type'])=='undefined';this.transId=Roo.lib.Ajax.request(E,B,cb,p,o);Roo.lib.Ajax.useDefaultHeader==true;
+return this.transId;}else{Roo.callback(o.callback,o.scope,[o,null,null]);return null;}},isLoading:function(A){if(A){return Roo.lib.Ajax.isCallInProgress(A);}else{return this.transId?true:false;}},abort:function(A){if(A||this.isLoading()){Roo.lib.Ajax.abort(A||this.transId);
+}},handleResponse:function(A){this.transId=false;var B=A.argument.options;A.argument=B?B.argument:null;this.fireEvent("requestcomplete",this,A,B);Roo.callback(B.success,B.scope,[A,B]);Roo.callback(B.callback,B.scope,[B,true,A]);},handleFailure:function(A,e){this.transId=false;
+var B=A.argument.options;A.argument=B?B.argument:null;this.fireEvent("requestexception",this,A,B,e);Roo.callback(B.failure,B.scope,[A,B]);Roo.callback(B.callback,B.scope,[B,false,A]);},doFormUpload:function(o,ps,A){var id=Roo.id();var B=document.createElement('iframe');
+B.id=id;B.name=id;B.className='x-hidden';if(Roo.isIE){B.src=Roo.SSL_SECURE_URL;}document.body.appendChild(B);if(Roo.isIE){document.frames[id].name=id;}var C=Roo.getDom(o.form);C.target=id;C.method='POST';C.enctype=C.encoding='multipart/form-data';if(A){C.action=A;
+}var D,hd;if(ps){D=[];ps=Roo.urlDecode(ps,false);for(var k in ps){if(ps.hasOwnProperty(k)){hd=document.createElement('input');hd.type='hidden';hd.name=k;hd.value=ps[k];C.appendChild(hd);D.push(hd);}}}function cb(){var r={responseText:'',responseXML:null};
+r.argument=o?o.argument:null;try{var F;if(Roo.isIE){F=B.contentWindow.document;}else{F=(B.contentDocument||window.frames[id].document);}if(F&&F.body){r.responseText=F.body.innerHTML;}if(F&&F.XMLDocument){r.responseXML=F.XMLDocument;}else{r.responseXML=F;}
+}catch(e){}Roo.EventManager.removeListener(B,'load',cb,this);this.fireEvent("requestcomplete",this,r,o);Roo.callback(o.success,o.scope,[r,o]);Roo.callback(o.callback,o.scope,[o,true,r]);setTimeout(function(){document.body.removeChild(B);},100);}Roo.EventManager.on(B,'load',cb,this);
+C.submit();if(D){for(var i=0,E=D.length;i<E;i++){C.removeChild(D[i]);}}},doFormDataUpload:function(o,ps,A){var B=Roo.getDom(o.form);B.enctype=B.encoding='multipart/form-data';var C=o.formData===true?new FormData(B):o.formData;var cb={success:this.handleResponse,failure:this.handleFailure,scope:this,argument:{options:o}
+,timeout:o.timeout||this.timeout};if(typeof o.autoAbort=='boolean'){if(o.autoAbort){this.abort();}}else if(this.autoAbort!==false){this.abort();}Roo.lib.Ajax.useDefaultHeader=false;this.transId=Roo.lib.Ajax.request("POST",A,cb,o.formData,o);Roo.lib.Ajax.useDefaultHeader=true;
+}});
 // Roo/Ajax.js
 Roo.Ajax=new Roo.data.Connection({autoAbort:false,serializeForm:function(A){return Roo.lib.Ajax.serializeForm(A);}});
 // Roo/UpdateManager.js
index 130983f..724a531 100644 (file)
@@ -11659,7 +11659,9 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, {
                 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
                 p = '';
             }
+            Roo.lib.Ajax.useDefaultHeader == typeof(o.headers['Content-Type']) == 'undefined';
             this.transId = Roo.lib.Ajax.request(method, url, cb, p, o);
+            Roo.lib.Ajax.useDefaultHeader == true;
             return this.transId;
         }else{
             Roo.callback(o.callback, o.scope, [o, null, null]);