Permalink
Browse files

ENYO-1476: Fix Android 2.3 test failure by forcing headers to be lowe…

…r-case in xhrResponse object. This changes the API, but since it's added in 2.1.1, it's not a break. Updated test to account for this.

Enyo-DCO-1.1-Signed-Off-By: Ben Combee (ben.combee@palm.com)
  • Loading branch information...
1 parent 257fb61 commit b8672af5099a6592b2d309b42ee9226e0e09239d Ben Combee committed Nov 21, 2012
Showing with 8 additions and 2 deletions.
  1. +7 −1 source/ajax/Ajax.js
  2. +1 −1 tools/test/ajax/tests/AjaxTest.js
View
@@ -51,6 +51,12 @@ enyo.kind({
The use of _inParams_ as a String is discouraged. Instead, set the request
body content via _postBody_ and use _inParams_ as an Object to set the query
string.
+
+ When the request is completed, the code will set a `xhrResponse` property
+ in the `enyo.Ajax` object with the subproperties `status`, `headers`, and
+ `body`. These cache the results from the XHR for later use. The keys for
+ the `headers` object have been converted to all lower case as HTTP headers
+ are case-insensitive.
*/
go: function(inParams) {
this.startTimer();
@@ -227,7 +233,7 @@ enyo.kind({
var headerStr = headersStr[i];
var index = headerStr.indexOf(': ');
if (index > 0) {
- var key = headerStr.substring(0, index);
+ var key = headerStr.substring(0, index).toLowerCase();
var val = headerStr.substring(index + 2);
headers[key] = val;
}
@@ -159,7 +159,7 @@ enyo.kind({
return (inError === 500) &&
req.xhrResponse &&
(req.xhrResponse.status === 500) &&
- (req.xhrResponse.headers['Content-Type'] === "text/plain; charset=utf-8") &&
+ (req.xhrResponse.headers['content-type'] === "text/plain; charset=utf-8") &&
(req.xhrResponse.body === "my error description");
});
}

0 comments on commit b8672af

Please sign in to comment.