wininet: Skip empty accept type strings in HttpOpenRequest.
This commit is contained in:
parent
f0f3e15ac2
commit
2024f68753
|
@ -803,11 +803,11 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
|
|||
if (lpszAcceptTypes)
|
||||
{
|
||||
/* find out how many there are */
|
||||
while (lpszAcceptTypes[acceptTypesCount])
|
||||
while (lpszAcceptTypes[acceptTypesCount] && *lpszAcceptTypes[acceptTypesCount])
|
||||
acceptTypesCount++;
|
||||
szAcceptTypes = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR *) * (acceptTypesCount+1));
|
||||
acceptTypesCount = 0;
|
||||
while (lpszAcceptTypes[acceptTypesCount])
|
||||
while (lpszAcceptTypes[acceptTypesCount] && *lpszAcceptTypes[acceptTypesCount])
|
||||
{
|
||||
len = MultiByteToWideChar(CP_ACP, 0, lpszAcceptTypes[acceptTypesCount],
|
||||
-1, NULL, 0 );
|
||||
|
@ -1111,12 +1111,17 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
|
|||
if (NULL != lpszReferrer && strlenW(lpszReferrer))
|
||||
HTTP_ProcessHeader(lpwhr, HTTP_REFERER, lpszReferrer, HTTP_ADDHDR_FLAG_COALESCE);
|
||||
|
||||
if(lpszAcceptTypes!=NULL)
|
||||
if (lpszAcceptTypes)
|
||||
{
|
||||
int i;
|
||||
for(i=0;lpszAcceptTypes[i]!=NULL;i++)
|
||||
for (i = 0; lpszAcceptTypes[i]; i++)
|
||||
{
|
||||
if (!*lpszAcceptTypes[i]) continue;
|
||||
HTTP_ProcessHeader(lpwhr, HTTP_ACCEPT, lpszAcceptTypes[i],
|
||||
HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA|HTTP_ADDHDR_FLAG_REQ|(i == 0 ? HTTP_ADDHDR_FLAG_REPLACE : 0));
|
||||
HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA |
|
||||
HTTP_ADDHDR_FLAG_REQ |
|
||||
(i == 0 ? HTTP_ADDHDR_FLAG_REPLACE : 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == lpszVerb)
|
||||
|
|
|
@ -632,6 +632,45 @@ done:
|
|||
ok(InternetCloseHandle(hSession), "Close session handle failed\n");
|
||||
}
|
||||
|
||||
static void InternetOpenRequest_test(void)
|
||||
{
|
||||
HINTERNET session, connect, request;
|
||||
static const char *types[] = { "*", "", NULL };
|
||||
static const WCHAR slash[] = {'/', 0}, any[] = {'*', 0}, empty[] = {0};
|
||||
static const WCHAR *typesW[] = { any, empty, NULL };
|
||||
BOOL ret;
|
||||
|
||||
session = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
||||
ok(session != NULL ,"Unable to open Internet session\n");
|
||||
|
||||
connect = InternetConnectA(session, "winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
|
||||
INTERNET_SERVICE_HTTP, 0, 0);
|
||||
ok(connect != NULL, "Unable to connect to http://winehq.org\n");
|
||||
|
||||
request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, types, INTERNET_FLAG_NO_CACHE_WRITE, 0);
|
||||
if (!request && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
|
||||
{
|
||||
trace( "Network unreachable, skipping test\n" );
|
||||
goto done;
|
||||
}
|
||||
ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
|
||||
|
||||
ret = HttpSendRequest(request, NULL, 0, NULL, 0);
|
||||
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
|
||||
ok(InternetCloseHandle(request), "Close request handle failed\n");
|
||||
|
||||
request = HttpOpenRequestW(connect, NULL, slash, NULL, NULL, typesW, INTERNET_FLAG_NO_CACHE_WRITE, 0);
|
||||
ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
|
||||
|
||||
ret = HttpSendRequest(request, NULL, 0, NULL, 0);
|
||||
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
|
||||
ok(InternetCloseHandle(request), "Close request handle failed\n");
|
||||
|
||||
done:
|
||||
ok(InternetCloseHandle(connect), "Close connect handle failed\n");
|
||||
ok(InternetCloseHandle(session), "Close session handle failed\n");
|
||||
}
|
||||
|
||||
static void HttpHeaders_test(void)
|
||||
{
|
||||
HINTERNET hSession;
|
||||
|
@ -1092,6 +1131,7 @@ START_TEST(http)
|
|||
InternetReadFile_test(INTERNET_FLAG_ASYNC);
|
||||
InternetReadFile_test(0);
|
||||
InternetReadFileExA_test(INTERNET_FLAG_ASYNC);
|
||||
InternetOpenRequest_test();
|
||||
InternetOpenUrlA_test();
|
||||
InternetTimeFromSystemTimeA_test();
|
||||
InternetTimeFromSystemTimeW_test();
|
||||
|
|
Loading…
Reference in New Issue