aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Karneges <justin@affinix.com>2013-01-30 17:34:59 -0800
committerJustin Karneges <justin@affinix.com>2013-01-30 17:34:59 -0800
commit03689f1cc5b4ad2b77acc1d08222987f7930fffc (patch)
treec3a10ff0ceaef736fea9b55a01b20ef85c01d6b6
parent62212280c2e3967ff5afe197a2356bc1b47d2b65 (diff)
downloadpollymer-03689f1cc5b4ad2b77acc1d08222987f7930fffc.tar
pollymer-03689f1cc5b4ad2b77acc1d08222987f7930fffc.tar.gz
remove debug define, parse response json-p headers
-rw-r--r--polldance.js25
1 files changed, 22 insertions, 3 deletions
diff --git a/polldance.js b/polldance.js
index 824fba3..c633da7 100644
--- a/polldance.js
+++ b/polldance.js
@@ -4,8 +4,8 @@
* Released under the MIT license (see COPYING file in source distribution)
*/
(function () {
-/** @define {boolean} */ var DEBUG = true;
"use strict";
+var DEBUG = true;
(function (window, undefined) {
var NAMESPACE = "PollDance";
@@ -48,6 +48,24 @@
}
};
+ var parseResponseHeaders = function(headerStr) {
+ var headers = {};
+ if (!headerStr) {
+ return headers;
+ }
+ var headerPairs = headerStr.split('\u000d\u000a');
+ for (var i = 0; i < headerPairs.length; i++) {
+ var headerPair = headerPairs[i];
+ var index = headerPair.indexOf('\u003a\u0020');
+ if (index > 0) {
+ var key = headerPair.substring(0, index);
+ var val = headerPair.substring(index + 2);
+ headers[key] = val;
+ }
+ }
+ return headers;
+ };
+
var jsonCallbacks = {
id: 0,
requests: {},
@@ -308,8 +326,9 @@
this._retry();
} else {
if (xhr.status) {
- // TODO: xhr.getAllResponseHeaders()
- this._handle_response(xhr.status, xhr.statusText, {}, xhr.responseText);
+ var headersStr = xhr.getAllResponseHeaders();
+ var headers = parseResponseHeaders(headersStr);
+ this._handle_response(xhr.status, xhr.statusText, headers, xhr.responseText);
} else {
this._error(errorTypes.TransportError);
}