diff options
Diffstat (limited to 'lib/caldav/request')
-rw-r--r-- | lib/caldav/request/abstract.js | 4 | ||||
-rw-r--r-- | lib/caldav/request/asset.js | 12 | ||||
-rw-r--r-- | lib/caldav/request/calendar_home.js | 13 |
3 files changed, 22 insertions, 7 deletions
diff --git a/lib/caldav/request/abstract.js b/lib/caldav/request/abstract.js index 7116217..9edf6fd 100644 --- a/lib/caldav/request/abstract.js +++ b/lib/caldav/request/abstract.js @@ -54,6 +54,8 @@ * @param {Function} callback node style callback. * Receives three arguments * error, parsedData, xhr. + * @return {Caldav.Xhr} The xhr request so that the caller + * has a chance to abort the request. */ send: function(callback) { var self = this; @@ -75,6 +77,8 @@ callback(new Errors.CaldavHttpError(xhr.status)); } }); + + return req; } }; diff --git a/lib/caldav/request/asset.js b/lib/caldav/request/asset.js index b26e4f7..98c943a 100644 --- a/lib/caldav/request/asset.js +++ b/lib/caldav/request/asset.js @@ -71,6 +71,8 @@ * * @param {Object} [options] calendar options. * @param {Function} callback node style [err, data, xhr]. + * @return {Caldav.Xhr} The underlying xhr request so that the caller + * has a chance to abort the request. */ get: function(options, callback) { if (typeof(options) === 'function') { @@ -80,7 +82,7 @@ var req = this._buildRequest('GET', options); - req.send(function(err, xhr) { + return req.send(function(err, xhr) { callback(err, xhr.responseText, xhr); }); }, @@ -91,6 +93,8 @@ * @param {Object} [options] see get. * @param {String} data post content. * @param {Function} callback node style [err, data, xhr]. + * @return {Caldav.Xhr} The underlying xhr request so that the caller + * has a chance to abort the request. */ put: function(options, data, callback) { if (typeof(options) === 'string') { @@ -106,7 +110,7 @@ var req = this._buildRequest('PUT', options); req.data = data; - req.send(function(err, xhr) { + return req.send(function(err, xhr) { callback(err, xhr.responseText, xhr); }); }, @@ -116,6 +120,8 @@ * * @param {Object} [options] see get. * @param {Function} callback node style [err, data, xhr]. + * @return {Caldav.Xhr} The underlying xhr request so that the caller + * has a chance to abort the request. */ delete: function(options, callback) { if (typeof(options) === 'function') { @@ -125,7 +131,7 @@ var req = this._buildRequest('DELETE', options); - req.send(function(err, xhr) { + return req.send(function(err, xhr) { callback(err, xhr.responseText, xhr); }); } diff --git a/lib/caldav/request/calendar_home.js b/lib/caldav/request/calendar_home.js index 24b27bc..a1f8ca6 100644 --- a/lib/caldav/request/calendar_home.js +++ b/lib/caldav/request/calendar_home.js @@ -52,6 +52,10 @@ Propfind: ns.require('request/propfind'), + /** + * @return {Caldav.Xhr} The underlying xhr request so that the caller + * has a chance to abort the request. + */ _findPrincipal: function(url, callback) { var find = new this.Propfind(this.connection, { url: url @@ -60,7 +64,7 @@ find.prop('current-user-principal'); find.prop('principal-URL'); - find.send(function(err, data) { + return find.send(function(err, data) { var principal; if (err) { @@ -81,7 +85,6 @@ } else { callback(new Errors.CaldavHttpError(404)); } - }); }, @@ -93,7 +96,7 @@ find.prop(['caldav', 'calendar-home-set']); - find.send(function(err, data) { + return find.send(function(err, data) { if (err) { callback(err); return; @@ -112,10 +115,12 @@ * * @param {Function} callback node style where second argument * are the details of the home calendar. + * @return {Caldav.Xhr} The underlying xhr request so that the caller + * has a chance to abort the request. */ send: function(callback) { var self = this; - self._findPrincipal(self.url, function(err, url) { + return self._findPrincipal(self.url, function(err, url) { if (!url) { callback(err); |