Browse Source

Fix xmlhttprequest.status if connection failed on firefox/safari

Pascal Peridont 19 years ago
parent
commit
70cadb5fe1
1 changed files with 9 additions and 3 deletions
  1. 9 3
      std/haxe/Http.hx

+ 9 - 3
std/haxe/Http.hx

@@ -54,10 +54,16 @@ class Http {
 		r.onreadystatechange = function() {
 		r.onreadystatechange = function() {
 			if( r.readyState != 4 )
 			if( r.readyState != 4 )
 				return;
 				return;
-			me.onStatus(r.status);
-			if( r.status >= 200 && r.status < 400 )
+			var s = try r.status catch( e : Dynamic ) null;
+			if( s == untyped __js__("undefined") )
+				s = null;
+			if( s != null )
+				me.onStatus(s);
+			if( s != null && s >= 200 && s < 400 )
 				me.onData(r.responseText);
 				me.onData(r.responseText);
-			else switch( r.status ) {
+			else switch( s ) {
+			case null:
+				me.onError("Failed to connect or resolve host");
 			case 12029:
 			case 12029:
 				me.onError("Failed to connect to host");
 				me.onError("Failed to connect to host");
 			case 12007:
 			case 12007: