[Pkg-javascript-commits] [dojo] 71/88: Fix content-type casing issues (1.8 backport). !strict refs #16532
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:39:40 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag 1.8.5
in repository dojo.
commit 86c4c894978176b3b46b899b51a02d520aea114e
Author: Bryan Forbes <bryan at reigndropsfall.net>
Date: Sun Mar 3 21:38:07 2013 +0000
Fix content-type casing issues (1.8 backport). !strict refs #16532
git-svn-id: http://svn.dojotoolkit.org/src/branches/1.8/dojo@30739 560b804f-0ae3-0310-86f3-f6aa0a117693
---
request/xhr.js | 7 ++-----
tests/request/xhr.html | 31 +++++++++++++++++++++++++++++-
tests/request/xhrEchoContentTypeHeader.php | 12 ++++++++++++
3 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/request/xhr.js b/request/xhr.js
index 99b3de4..ad8a53b 100644
--- a/request/xhr.js
+++ b/request/xhr.js
@@ -122,10 +122,7 @@ define([
data: null,
query: null,
sync: false,
- method: 'GET',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
+ method: 'GET'
};
function xhr(url, options, returnDeferred){
var response = util.parseArgs(
@@ -180,7 +177,7 @@ define([
}
var headers = options.headers,
- contentType;
+ contentType = 'application/x-www-form-urlencoded';
if(headers){
for(var hdr in headers){
if(hdr.toLowerCase() === 'content-type'){
diff --git a/tests/request/xhr.html b/tests/request/xhr.html
index 3620ce7..fa60efb 100644
--- a/tests/request/xhr.html
+++ b/tests/request/xhr.html
@@ -17,12 +17,13 @@
require([
"dojo/request/xhr",
"dojo/_base/lang",
+ "dojo/promise/all",
"dojo/errors/RequestTimeoutError",
"dojo/errors/CancelError",
"dojo/has",
"doh",
"dojo/domReady!"
- ], function(xhr, lang, RequestTimeoutError, CancelError, has, doh){
+ ], function(xhr, lang, all, RequestTimeoutError, CancelError, has, doh){
var tests = [
function xhrGet(t){
var d = new doh.Deferred();
@@ -238,6 +239,34 @@
d.errback(error);
});
return d;
+ },
+
+ function xhrCustomContentType(t){
+ var d = new doh.Deferred();
+
+ function postWithHeaders(headers){
+ return xhr.post("xhrEchoContentTypeHeader.php",{
+ headers: headers,
+ data: "",
+ handleAs: "text"
+ });
+ }
+
+ var expectedContentType = "application/x-test-xhr";
+
+ // Test uppercase and lowercase header names to demonstrate case insensitivity
+ all({
+ lowercaseContentType: postWithHeaders({ "content-type": expectedContentType }),
+ uppercaseContentType: postWithHeaders({ "CONTENT-TYPE": expectedContentType })
+ }).then(d.getTestCallback(function(results){
+ // Strip any header parameters added by browser for the request.
+ t.is(expectedContentType, results.lowercaseContentType.split(";")[0]);
+ t.is(expectedContentType, results.uppercaseContentType.split(";")[0]);
+ }), function(error){
+ d.errback(error);
+ });
+
+ return d;
}
];
diff --git a/tests/request/xhrEchoContentTypeHeader.php b/tests/request/xhrEchoContentTypeHeader.php
new file mode 100644
index 0000000..6e11906
--- /dev/null
+++ b/tests/request/xhrEchoContentTypeHeader.php
@@ -0,0 +1,12 @@
+<?php
+
+header("HTTP/1.1 200 OK");
+header("Expires: " . gmdate("D, d M Y H:i:s") . "GMT");
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-type: text/plain");
+
+echo $_SERVER["CONTENT_TYPE"]
+
+?>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git
More information about the Pkg-javascript-commits
mailing list