From 95fe95710b81d14dda2a3b77281f1fe65f703ef3 Mon Sep 17 00:00:00 2001 From: James Lal Date: Tue, 26 Jun 2012 12:29:36 +0200 Subject: add user/pass options to abstract request --- lib/webcals/request/abstract.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'lib/webcals/request') diff --git a/lib/webcals/request/abstract.js b/lib/webcals/request/abstract.js index ac0ceb5..4d549c2 100644 --- a/lib/webcals/request/abstract.js +++ b/lib/webcals/request/abstract.js @@ -11,13 +11,29 @@ * @param {Object} options additional options for request. */ function Abstract(url, options) { + if (typeof(options) === 'undefined') { + options = {}; + } + var key; + var xhrOptions = {}; if (typeof(url) === 'undefined' || !url) { throw new Error('request requires a url'); } - this.url = url; + xhrOptions.url = url; + + if ('password' in options) { + xhrOptions.password = options.password; + delete options.password; + } + + if ('user' in options) { + xhrOptions.user = options.user; + delete options.user; + } + this.sax = new SAX(); for (key in options) { @@ -26,9 +42,7 @@ } } - this.xhr = new XHR({ - url: this.url - }); + this.xhr = new XHR(xhrOptions); } Abstract.prototype = { -- cgit