Skip to content

Commit

Permalink
make xhr.open in _send synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
pfn committed May 30, 2012
1 parent 2b11f10 commit c7021bc
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions modules/KeePassFox.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -341,19 +341,11 @@ KeePassFox.prototype = {
_send: function(request) {
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Ci.nsIXMLHttpRequest);
xhr.open("POST", KEEPASS_HTTP_URL, true);
xhr.open("POST", KEEPASS_HTTP_URL, false);
xhr.setRequestHeader("Content-Type", "application/json");
let running = true;
try {
let r = JSON.stringify(request);
this.log("REQUEST: " + r);
xhr.onabort = xhr.onerror = xhr.onload = function() running = false;
xhr.send(r);
}
catch (e) { running = false; this.log("KeePassHttp: " + e); }

while (running)
Services.tm.currentThread.processNextEvent(true);
let r = JSON.stringify(request);
this.log("REQUEST: " + r);
xhr.send(r);

this.log("RESPONSE: " + xhr.status + " => " + xhr.responseText);
return [xhr.status, xhr.responseText, xhr.readyState];
Expand Down

0 comments on commit c7021bc

Please sign in to comment.