InternetOpenUrlA (http/s case): Use client for HttpOpenRequestA, don't
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Tue, 25 Feb 2003 03:57:59 +0000 (03:57 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 25 Feb 2003 03:57:59 +0000 (03:57 +0000)
insert HOST: twice.
HttpAddRequestHeadersA: allow lpszHeader == NULL.

dlls/wininet/http.c
dlls/wininet/internet.c
dlls/wininet/tests/http.c

index 73d9dc40d04051393efd8878f1ddfd3dbc0f1a9c..5822264317f235d44f4de61731cb33e613db7d8e 100644 (file)
@@ -119,6 +119,8 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
         return FALSE;
     }
 
+    if (!lpszHeader) 
+      return TRUE;
     buffer = HTTP_strdup(lpszHeader);
     lpszStart = buffer;
 
index e3c8c5a25d0c99693f93b9f096e22072f8192a2d..c1e8ea64ebf57a46a1870ce96283b448665ea34f 100644 (file)
@@ -1736,13 +1736,12 @@ HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
         password, INTERNET_SERVICE_HTTP, dwFlags, dwContext);
     if(client == NULL)
       return NULL;
-    client1 = HttpOpenRequestA(hInternet, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
+    client1 = HttpOpenRequestA(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
     if(client1 == NULL) {
       InternetCloseHandle(client);
       return NULL;
     }
     HttpAddRequestHeadersA(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
-    HttpAddRequestHeadersA(client1, hostreq, -1L, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
     if(!HttpSendRequestA(client1, NULL, 0, NULL, 0)) {
       InternetCloseHandle(client1);
       InternetCloseHandle(client);
index 2af222960a2716a81319c1bca84b1e876c7b0f20..4c2b19acf4c7fa041a25f4c836f07554fdd92a3b 100644 (file)
@@ -202,9 +202,75 @@ abort:
     }
 }
 
+void InternetOpenUrlA_test(void)
+{
+  HINTERNET myhinternet, myhttp;
+  char buffer[0x400];
+  URL_COMPONENTSA urlComponents;
+  char protocol[32], hostName[1024], userName[1024];
+  char password[1024], extra[1024], path[1024];
+  DWORD size, readbytes, totalbytes=0;
+  
+  myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
+  ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
+  size = 0x400;
+  ok (InternetCanonicalizeUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz",buffer, &size,ICU_BROWSER_MODE),
+      "InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
+  
+  urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
+  urlComponents.lpszScheme = protocol;
+  urlComponents.dwSchemeLength = 32;
+  urlComponents.lpszHostName = hostName;
+  urlComponents.dwHostNameLength = 1024;
+  urlComponents.lpszUserName = userName;
+  urlComponents.dwUserNameLength = 1024;
+  urlComponents.lpszPassword = password;
+  urlComponents.dwPasswordLength = 1024;
+  urlComponents.lpszUrlPath = path;
+  urlComponents.dwUrlPathLength = 2048;
+  urlComponents.lpszExtraInfo = extra;
+  urlComponents.dwExtraInfoLength = 1024;
+  ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
+     "InternetCrackUrl failed, error %lx\n",GetLastError());
+  myhttp = InternetOpenUrl(myhinternet, "http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0, 0,
+                          INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
+  ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
+  ok(InternetReadFile(myhttp, buffer,0x400,&readbytes), "InternetReadFile failed, error %lx\n",GetLastError());
+  totalbytes += readbytes;
+  while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
+    totalbytes += readbytes;
+  printf("read 0x%08lx bytes\n",totalbytes);
+}
+  
+void InternetCrackUrl_test(void)
+{
+  URL_COMPONENTSA urlComponents;
+  char protocol[32], hostName[1024], userName[1024];
+  char password[1024], extra[1024], path[1024];
+
+  urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
+  urlComponents.lpszScheme = protocol;
+  urlComponents.dwSchemeLength = 32;
+  urlComponents.lpszHostName = hostName;
+  urlComponents.dwHostNameLength = 1024;
+  urlComponents.lpszUserName = userName;
+  urlComponents.dwUserNameLength = 1024;
+  urlComponents.lpszPassword = password;
+  urlComponents.dwPasswordLength = 1024;
+  urlComponents.lpszUrlPath = path;
+  urlComponents.dwUrlPathLength = 2048;
+  urlComponents.lpszExtraInfo = extra;
+  urlComponents.dwExtraInfoLength = 1024;
+  ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
+     "InternetCrackUrl failed, error %lx\n",GetLastError());
+  ok((strcmp("/fieldsync2/release.log.gz",path) == 0),"path cracked wrong");
+}
 
 START_TEST(http)
 {
     winapi_test(0x10000000);
     winapi_test(0x00000000);
+    InternetCrackUrl_test();
+    InternetOpenUrlA_test();
+    
 }