diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 73d9dc40d04..5822264317f 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -119,6 +119,8 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest, return FALSE; } + if (!lpszHeader) + return TRUE; buffer = HTTP_strdup(lpszHeader); lpszStart = buffer; diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index e3c8c5a25d0..c1e8ea64ebf 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -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); diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 2af222960a2..4c2b19acf4c 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -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(); + }