[tor-commits] [flashproxy/master] Fix logic around XMLHttpRequest errors.

dcf at torproject.org dcf at torproject.org
Mon Apr 9 04:08:42 UTC 2012


commit 888e29ea479df363b948dd308682d57cd7ba39f2
Author: David Fifield <david at bamsoftware.com>
Date:   Sat Mar 24 21:33:32 2012 -0700

    Fix logic around XMLHttpRequest errors.
    
    I had confused the status and readyState members in a way that hid the
    same-origin failure error condition.
---
 flashproxy.js |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/flashproxy.js b/flashproxy.js
index 67620f7..43c2342 100644
--- a/flashproxy.js
+++ b/flashproxy.js
@@ -147,14 +147,14 @@ function FlashProxy()
         }
         xhr.responseType = "text";
         xhr.onreadystatechange = function() {
-            /* Status 0 is UNSENT. 4 is DONE. */
-            if (xhr.status == 0 && xhr.statusText == null) {
-                this.puts("Facilitator: cross-domain error.");
-            } else if (xhr.readyState == 4) {
+            /* Status 4 is DONE. */
+            if (xhr.readyState == 4) {
                 if (xhr.status == 200)
                     this.fac_complete(xhr.responseText);
+                else if (xhr.status == 0 && xhr.statusText == "")
+                    this.puts("Facilitator: same-origin error.");
                 else
-                    this.puts("Facilitator: can't connect: got response code " + xhr.status + ".");
+                    this.puts("Facilitator: can't connect: got status " + repr(xhr.status) + " and status text " + repr(xhr.statusText) + ".");
             }
         }.bind(this);
         this.puts("Facilitator: connecting to " + fac_url + ".");





More information about the tor-commits mailing list