aboutsummaryrefslogtreecommitdiffstats
path: root/caldav.js
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2013-01-07 18:39:12 +0100
committerJames Lal <james@lightsofapollo.com>2013-01-07 18:39:12 +0100
commit843b96d1822a28cee8eed1776aa37b6322432249 (patch)
treed39a4be437ce1d0042bca92517ae674d219611b4 /caldav.js
parent3170505852bbb6379a712ff816e1715f512516ad (diff)
downloadjsCalDAV-843b96d1822a28cee8eed1776aa37b6322432249.tar.gz
don't hold onto .xhr in request
Diffstat (limited to 'caldav.js')
-rw-r--r--caldav.js28
1 files changed, 9 insertions, 19 deletions
diff --git a/caldav.js b/caldav.js
index 32cfb34..6975f65 100644
--- a/caldav.js
+++ b/caldav.js
@@ -2040,15 +2040,6 @@ function write (chunk) {
},
/**
- * Aborts request if its in progress.
- */
- abort: function abort() {
- if (this.xhr) {
- this.xhr.abort();
- }
- },
-
- /**
* @param {String} user basic auth user.
* @param {String} password basic auth pass.
* @return {String} basic auth token.
@@ -2078,8 +2069,6 @@ function write (chunk) {
xhr = new this.xhrClass();
}
- this.xhr = xhr;
-
// This hack is in place due to some platform
// bug in gecko when using mozSystem xhr
// the credentials only seem to work as expected
@@ -2136,6 +2125,8 @@ function write (chunk) {
this.waiting = true;
xhr.send(this._seralize());
+
+ return xhr;
}
};
@@ -2602,26 +2593,26 @@ function write (chunk) {
default:
message = this.code;
}
-
Error.call(this, message);
}
+
CaldavHttpError.prototype = {
__proto__: Error.prototype,
constructor: CaldavHttpError
}
-
+
// Unauthenticated error for
// Google Calendar
function UnauthenticatedError() {
var message = "Wrong username or/and password";
Error.call(this, message);
}
-
+
UnauthenticatedError.prototype = {
__proto__: Error.prototype,
constructor: UnauthenticatedError
}
-
+
module.exports = {
CaldavHttpError: CaldavHttpError,
UnauthenticatedError: UnauthenticatedError
@@ -2700,8 +2691,7 @@ function write (chunk) {
};
// in the future we may stream data somehow
- req.send(function xhrResult() {
- var xhr = req.xhr;
+ req.send(function xhrResult(err, xhr) {
if (xhr.status > 199 && xhr.status < 300) {
// success
self.sax.close();
@@ -3021,8 +3011,7 @@ function write (chunk) {
content += this.filter.toString();
}
- var out = this.template.render(content);
- return out;
+ return this.template.render(content);
}
};
@@ -3110,6 +3099,7 @@ function write (chunk) {
if (!principal) {
principal = findProperty('principal-URL', data, true);
}
+
if ('unauthenticated' in principal) {
callback(new Errors.UnauthenticatedError());
} else if (principal.href){