[Commits] r2005 - in core/trunk/geoext: lib/overrides tests/lib/overrides
commits at geoext.org
commits at geoext.org
Thu Mar 18 11:05:57 CET 2010
Author: bbinet
Date: 2010-03-18 11:05:57 +0100 (Thu, 18 Mar 2010)
New Revision: 2005
Modified:
core/trunk/geoext/lib/overrides/override-ext-ajax.js
core/trunk/geoext/tests/lib/overrides/override-ext-ajax.html
Log:
override-ext-ajax modify content type for non post requests anymore, r=bartvde (closes #240)
Modified: core/trunk/geoext/lib/overrides/override-ext-ajax.js
===================================================================
--- core/trunk/geoext/lib/overrides/override-ext-ajax.js 2010-03-18 07:20:37 UTC (rev 2004)
+++ core/trunk/geoext/lib/overrides/override-ext-ajax.js 2010-03-18 10:05:57 UTC (rev 2005)
@@ -29,27 +29,29 @@
*/
request: function(method, uri, cb, data, options) {
options = options || {};
+ method = method || options.method;
var hs = options.headers;
if(options.xmlData) {
if(!hs || !hs["Content-Type"]) {
hs = hs || {};
hs["Content-Type"] = "text/xml";
}
- method = (method ? method :
- (options.method ? options.method : "POST"));
+ method = method || "POST";
data = options.xmlData;
} else if(options.jsonData) {
if(!hs || !hs["Content-Type"]) {
hs = hs || {};
hs["Content-Type"] = "application/json";
}
- method = (method ? method :
- (options.method ? options.method : "POST"));
+ method = method || "POST";
data = typeof options.jsonData == "object" ?
Ext.encode(options.jsonData) : options.jsonData;
}
- // options.form or options.params means form-encoded data, so change content-type
- if ((options.form || options.params) && (!hs || !hs["Content-Type"])) {
+ // if POST method, options.form or options.params means
+ // form-encoded data, so change content-type
+ if ((method && method.toLowerCase() == "post") &&
+ (options.form || options.params) &&
+ (!hs || !hs["Content-Type"])) {
hs = hs || {};
hs["Content-Type"] = "application/x-www-form-urlencoded";
}
Modified: core/trunk/geoext/tests/lib/overrides/override-ext-ajax.html
===================================================================
--- core/trunk/geoext/tests/lib/overrides/override-ext-ajax.html 2010-03-18 07:20:37 UTC (rev 2004)
+++ core/trunk/geoext/tests/lib/overrides/override-ext-ajax.html 2010-03-18 10:05:57 UTC (rev 2005)
@@ -187,6 +187,34 @@
});
}
+
+ function test_paramsGet(t) {
+ t.plan(0);
+ /*
+ * Setup
+ */
+ setup();
+
+ var proto = OpenLayers.Request.XMLHttpRequest.prototype;
+ var _srh = proto.setRequestHeader;
+ proto.setRequestHeader = function(k, v) {
+ t.eq(k == "Content-Type" && v != "application/x-www-form-urlencoded",
+ "Content-Type header should not be set for GET request");
+ };
+ Ext.Ajax.request({
+ failure: function(response) { },
+ method: 'GET',
+ success: function(response) { },
+ params: { xx: 'xx', yy: 'yy'},
+ url: 'foo.php'
+ });
+ proto.setRequestHeader = _srh;
+
+ /*
+ * Teardown
+ */
+ teardown();
+ }
</script>
<body>
<div id="basicform"></div>
More information about the Commits
mailing list