diff options
author | harmony7 <harmony7@pex2.jp> | 2013-04-21 11:32:43 +0900 |
---|---|---|
committer | harmony7 <harmony7@pex2.jp> | 2013-04-21 11:32:43 +0900 |
commit | a8b36f2bb7acc298cbbd1ab7efa9e13bfaa3b708 (patch) | |
tree | 5627c25fd446d86dafb1bfab16b1ef2c530b19e9 | |
parent | 74e587b1b6d6349f50c082ed7afece8d43be546d (diff) | |
download | pollymer-a8b36f2bb7acc298cbbd1ab7efa9e13bfaa3b708.tar pollymer-a8b36f2bb7acc298cbbd1ab7efa9e13bfaa3b708.tar.gz |
Support for the withCredentials bit of XHR, used with CORS
-rw-r--r-- | pollymer.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pollymer.js b/pollymer.js index d4cd078..699f7db 100644 --- a/pollymer.js +++ b/pollymer.js @@ -205,6 +205,7 @@ var DEBUG = true; this.maxTries = 1; this.maxDelay = 1000; this.recurring = false; + this.withCredentials = false; if (arguments.length > 0) { var config = arguments[0]; @@ -223,6 +224,9 @@ var DEBUG = true; if ("recurring" in config) { this.recurring = config.recurring; } + if ("withCredentials" in config) { + this.withCredentials = config.withCredentials; + } } }; Request.prototype.start = function (method, url, headers, body) { @@ -328,6 +332,13 @@ var DEBUG = true; }; Request.prototype._startXhr = function (method, url, headers, body) { var xhr = new window.XMLHttpRequest(); + + // If header has Authorization, and cors is available, then set the + // withCredentials flag. + if (this.withCredentials && corsAvailable) { + xhr.withCredentials = true; + } + var self = this; xhr.onreadystatechange = function () { self._xhrCallback(); }; xhr.open(method, url, true); |