Hans Leidekker : wininet: Skip empty accept type strings in
HttpOpenRequest .
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Feb 13 11:07:42 CST 2007
Module: wine
Branch: master
Commit: 2024f687535edeb0413e0f86ca15877982573762
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2024f687535edeb0413e0f86ca15877982573762
Author: Hans Leidekker <hans at it.vu.nl>
Date: Mon Feb 12 15:19:17 2007 +0100
wininet: Skip empty accept type strings in HttpOpenRequest.
---
dlls/wininet/http.c | 15 ++++++++++-----
dlls/wininet/tests/http.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 8a34749..17e48c9 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -803,11 +803,11 @@ HINTERNET WINAPI HttpOpenRequestA(HINTER
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(L
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)
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 876e616..664447d 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -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();
More information about the wine-cvs
mailing list