diff options
author | James Lal <james@lightsofapollo.com> | 2012-07-06 14:52:13 -0700 |
---|---|---|
committer | James Lal <james@lightsofapollo.com> | 2012-07-06 14:52:13 -0700 |
commit | 684ec0e95608e3212d8dac1b2c7489cf7e5c3078 (patch) | |
tree | 15ff517b5715f4f32f44a70c2698caeb9426ee28 /lib/caldav/request/abstract.js | |
parent | fa1bc078c2953c4d81d7c5c17e4f3a4c0e3febeb (diff) | |
download | jsCalDAV-684ec0e95608e3212d8dac1b2c7489cf7e5c3078.tar.gz |
Reworked requests to take connection object and options
Diffstat (limited to 'lib/caldav/request/abstract.js')
-rw-r--r-- | lib/caldav/request/abstract.js | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/lib/caldav/request/abstract.js b/lib/caldav/request/abstract.js index 4b72fd5..cc60391 100644 --- a/lib/caldav/request/abstract.js +++ b/lib/caldav/request/abstract.js @@ -7,10 +7,10 @@ /** * Creates an (Web/Cal)Dav request. * - * @param {String} url location of resource. + * @param {Caldav.Connection} connection connection details. * @param {Object} options additional options for request. */ - function Abstract(url, options) { + function Abstract(connection, options) { if (typeof(options) === 'undefined') { options = {}; } @@ -18,22 +18,6 @@ var key; var xhrOptions = {}; - if (typeof(url) === 'undefined' || !url) { - throw new Error('request requires a 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) { @@ -42,8 +26,16 @@ } } - this.xhr = new XHR(xhrOptions); - this.xhr.headers['Content-Type'] = 'text/xml'; + if (!connection) { + throw new Error('must pass connection object'); + } + + this.connection = connection; + + this.xhr = this.connection.request({ + url: this.url, + headers: { 'Content-Type': 'text/xml' } + }); } Abstract.prototype = { |