From 0565aab9ebab79642b3ec6ea27170eb169508ccc Mon Sep 17 00:00:00 2001 From: aaron Date: Sun, 18 Jan 2015 23:56:39 -0800 Subject: [PATCH] Expose xhr.withCredentials with correct default Fixes #71 Replaces #84 --- lib/XMLHttpRequest.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/XMLHttpRequest.js b/lib/XMLHttpRequest.js index 949fdf9..9e5351c 100644 --- a/lib/XMLHttpRequest.js +++ b/lib/XMLHttpRequest.js @@ -110,6 +110,10 @@ exports.XMLHttpRequest = function() { this.responseXML = ""; this.status = null; this.statusText = null; + + // Whether cross-site Access-Control requests should be made using + // credentials such as cookies or authorization headers + this.withCredentials = false; /** * Private methods @@ -363,7 +367,8 @@ exports.XMLHttpRequest = function() { path: uri, method: settings.method, headers: headers, - agent: false + agent: false, + withCredentials: self.withCredentials }; // Reset error flag @@ -399,7 +404,8 @@ exports.XMLHttpRequest = function() { port: url.port, path: url.path, method: response.statusCode === 303 ? "GET" : settings.method, - headers: headers + headers: headers, + withCredentials: self.withCredentials }; // Issue the new request