From 843b96d1822a28cee8eed1776aa37b6322432249 Mon Sep 17 00:00:00 2001 From: James Lal Date: Mon, 7 Jan 2013 18:39:12 +0100 Subject: don't hold onto .xhr in request --- caldav.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'caldav.js') diff --git a/caldav.js b/caldav.js index 32cfb34..6975f65 100644 --- a/caldav.js +++ b/caldav.js @@ -2039,15 +2039,6 @@ function write (chunk) { return this.data; }, - /** - * 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. @@ -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){ -- cgit