Commit 1cd00dae authored by Uwe Bonnes's avatar Uwe Bonnes Committed by Alexandre Julliard

InternetOpenUrlA (http/s case): Use client for HttpOpenRequestA, don't

insert HOST: twice. HttpAddRequestHeadersA: allow lpszHeader == NULL.
parent 1b74cf2c
......@@ -119,6 +119,8 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
return FALSE;
}
if (!lpszHeader)
return TRUE;
buffer = HTTP_strdup(lpszHeader);
lpszStart = buffer;
......
......@@ -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);
......
......@@ -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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment