소스 검색

Fix xmlhttprequest.status if connection failed on firefox/safari

Pascal Peridont 19 년 전
부모
커밋
70cadb5fe1
1개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 3
      std/haxe/Http.hx

+ 9 - 3
std/haxe/Http.hx

@@ -54,10 +54,16 @@ class Http {
 		r.onreadystatechange = function() {
 			if( r.readyState != 4 )
 				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);
-			else switch( r.status ) {
+			else switch( s ) {
+			case null:
+				me.onError("Failed to connect or resolve host");
 			case 12029:
 				me.onError("Failed to connect to host");
 			case 12007: