Don't fail wininet tests behind a firewall

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



*** firewall

* dlls/wininet/tests/http.c:
Fixed test to not fail behind firewalls or
without an internet connection.

Index: wine/dlls/wininet/tests/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/tests/http.c,v
retrieving revision 1.2
diff -u -u -r1.2 http.c
--- wine/dlls/wininet/tests/http.c	17 Sep 2002 00:04:35 -0000	1.2
+++ wine/dlls/wininet/tests/http.c	7 Oct 2002 18:32:36 -0000
@@ -90,6 +90,8 @@
     ok((hi != 0x0),"InternetOpen Failed");
     trace("InternetOpenA -->\n");
 
+    if (hi == 0x0) goto abort;
+
     InternetSetStatusCallback(hi,&callback);
 
     trace("InternetConnectA <--\n");
@@ -97,6 +99,8 @@
     ok((hic != 0x0),"InternetConnect Failed");
     trace("InternetConnectA -->\n");
 
+    if (hic == 0x0) goto abort;
+
     types = (char*)malloc(100);
     strcpy(types,"*");
 
@@ -104,10 +108,20 @@
     hor = HttpOpenRequestA(hic, "GET",
                           "/about/",
                           0x0,0x0,(const
char**)&types,0x00400800,0xdeadbead);
-
-    ok((hor != 0x0),"HttpOpenRequest Failed");
+    if (hor == 0x0 && GetLastError() == 12007 /*
ERROR_INTERNET_NAME_NOT_RESOLVED */) {
+        /*
+         * If the internet name can't be resolved we are probably behind
+         * a firewall or in some other way not directly connected to the
+         * Internet. Not enough reason to fail the test. Just ignore and
+         * abort.
+         */
+    } else  {
+        ok((hor != 0x0),"HttpOpenRequest Failed");
+    }
     trace("HttpOpenRequestA -->\n");
 
+    if (hor == 0x0) goto abort;
+
     trace("HttpSendRequestA -->\n");
     rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0);
     if (flags)
@@ -170,12 +184,21 @@
             HeapFree(GetProcessHeap(),0,buffer);
         }
     }
-    rc = InternetCloseHandle(hi);
-    ok ((rc != 0), "InternetCloseHandle failed");
-    rc = InternetCloseHandle(hor);
-    ok ((rc != 0), "InternetCloseHandle failed");
-    if (flags)
-        Sleep(100);
+abort:
+    if (hor != 0x0) {
+        rc = InternetCloseHandle(hor);
+        ok ((rc != 0), "InternetCloseHandle of handle opened by
HttpOpenRequestA failed");
+    }
+    if (hor != 0x0) {
+        rc = InternetCloseHandle(hic);
+        ok ((rc != 0), "InternetCloseHandle of handle opened by
InternetConnectA failed");
+    }
+    if (hi != 0x0) {
+      rc = InternetCloseHandle(hi);
+      ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA
failed");
+      if (flags)
+          Sleep(100);
+    }
 }
 
 


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux