Backed out changeset 129ca9a54aed due to burning

test_auth_manager:      FAIL
test_resource:  FAIL
This commit is contained in:
Edward Lee 2009-08-26 01:50:36 -07:00
parent adf361843a
commit 852bb71758
3 changed files with 11 additions and 69 deletions

View File

@ -218,10 +218,7 @@ SyncEngine.prototype = {
__proto__: Engine.prototype,
_recordObj: CryptoWrapper,
_alerts: "",
get alerts() { return this._alerts; },
get baseURL() {
let url = Svc.Prefs.get("clusterURL");
if (!url)
@ -344,15 +341,8 @@ SyncEngine.prototype = {
Sync.sleep(0);
});
let resp = newitems.get();
try {
// we only need to store the latest alert
this._alerts = resp.getHeader("X-Weave-Alert");
} catch (e) {
// no alert headers were present
this._alerts = "";
}
newitems.get();
if (this.lastSync < this._lastSyncTmp)
this.lastSync = this._lastSyncTmp;

View File

@ -50,23 +50,6 @@ Cu.import("resource://weave/constants.js");
Cu.import("resource://weave/util.js");
Cu.import("resource://weave/auth.js");
// = RequestResponse =
//
// This object is returned on a successful
// HTTP response (codes 200-300) and encapsulates
// returned headers and the actual response text
function RequestResponse(channel, response) {
this._channel = channel;
this._response = response;
}
RequestResponse.prototype = {
get response() { return this._response },
get status() { return this._channel.responseStatus },
getHeader: function ReqRe_getHeader(which) {
return this._channel.getResponseHeader(which);
}
};
// = RequestException =
//
// This function raises an exception through the call
@ -310,7 +293,7 @@ Resource.prototype = {
this._log.debug(action + " request failed (" + channel.responseStatus + ")");
if (this._data)
this._log.debug("Error response: " + this._data);
return new RequestResponse(channel, this._data);
throw new RequestException(this, action, channel);
} else {
this._log.debug(action + " request successful (" + channel.responseStatus + ")");
@ -330,7 +313,7 @@ Resource.prototype = {
}
}
return new RequestResponse(channel, this._data);
return this._data;
},
// ** {{{ Resource.get }}} **

View File

@ -172,10 +172,6 @@ WeaveSvc.prototype = {
// Timer object for automagically syncing
_syncTimer: null,
// Current alerts
_alerts: "[]",
get alerts() { return JSON.parse(this._alerts); },
get username() {
return Svc.Prefs.get("username", "");
},
@ -536,38 +532,17 @@ WeaveSvc.prototype = {
};
// login may fail because of cluster change
let response;
try {
response = res.get();
res.get();
} catch (e) {}
if (response) {
switch (response.status) {
try {
switch (res.lastChannel.responseStatus) {
case 200:
if (passphrase &&
!this.verifyPassphrase(username, password, passphrase)) {
if (passphrase && !this.verifyPassphrase(username, password, passphrase)) {
this._setSyncFailure(LOGIN_FAILED_INVALID_PASSPHRASE);
return false;
}
// check for alerts
try {
let alerts = response.getHeader("X-Weave-Alert");
if (this._alerts != alerts) {
this._alerts = alerts;
Svc.Observer.notifyObservers(
null, "weave:service:alerts:changed", ""
);
}
} catch (e) {
// no alert headers were present
if (this.alerts.length != 0) {
this._alerts = "";
Svc.Observer.notifyObservers(
null, "weave:service:alerts:changed", ""
);
}
}
return true;
case 401:
if (this.updateCluster(username))
@ -579,9 +554,9 @@ WeaveSvc.prototype = {
default:
throw "unexpected HTTP response: " + res.lastChannel.responseStatus;
}
} else {
} catch (e) {
// if we get here, we have either a busted channel or a network error
this._log.debug("verifyLogin failed: network error");
this._log.debug("verifyLogin failed: " + e)
this._setSyncFailure(LOGIN_FAILED_NETWORK_ERROR);
throw e;
}
@ -1247,12 +1222,6 @@ WeaveSvc.prototype = {
_syncEngine: function WeaveSvc__syncEngine(engine) {
try {
engine.sync();
if (this._alerts != engine.alerts) {
this._alerts = engine.alerts;
Svc.Observer.notifyObservers(
null, "weave:service:alerts:changed", ""
);
}
return true;
}
catch(e) {