From a8b36f2bb7acc298cbbd1ab7efa9e13bfaa3b708 Mon Sep 17 00:00:00 2001 From: harmony7 Date: Sun, 21 Apr 2013 11:32:43 +0900 Subject: Support for the withCredentials bit of XHR, used with CORS --- pollymer.js | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); -- cgit v1.2.3