ChangeSet ID: 21397 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/22 08:53:30
Modified files: dlls/wininet/tests: http.c dlls/wininet : http.c
Log message: Aric Stewart aric@codeweavers.com Fix some logic to allow HTTP_ADDREQ_FLAG_ADD to replace existing headers. Also adding a test for some header adding flags.
Patch: http://cvs.winehq.org/patch.py?id=21397
Old revision New revision Changes Path 1.33 1.34 +31 -1 wine/dlls/wininet/tests/http.c 1.112 1.113 +4 -2 wine/dlls/wininet/http.c
Index: wine/dlls/wininet/tests/http.c diff -u -p wine/dlls/wininet/tests/http.c:1.33 wine/dlls/wininet/tests/http.c:1.34 --- wine/dlls/wininet/tests/http.c:1.33 22 Nov 2005 14:53:30 -0000 +++ wine/dlls/wininet/tests/http.c 22 Nov 2005 14:53:30 -0000 @@ -1113,7 +1113,36 @@ static void HttpSendRequestEx_test(void) ok(InternetCloseHandle(hConnect), "Close connect handle failed\n"); ok(InternetCloseHandle(hSession), "Close session handle failed\n"); } - + +static void HttpHeaders_test(void) +{ + HINTERNET hSession; + HINTERNET hConnect; + HINTERNET hRequest; + + hSession = InternetOpen("Wine Regression Test", + INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0); + ok( hSession != NULL ,"Unable to open Internet session\n"); + hConnect = InternetConnect(hSession, "crossover.codeweavers.com", + INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, + 0); + ok( hConnect != NULL, "Unable to connect to http://crossover.codeweavers.com%5Cn"); + hRequest = HttpOpenRequest(hConnect, "POST", "/posttest.php", + NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0); + ok( hRequest != NULL, "Failed to open request handle\n"); + + ok(HttpAddRequestHeaders(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD), "Failed to add new header\n"); + ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD), "Failed to replace header using HTTP_ADDREQ_FLAG_ADD\n"); + ok(HttpAddRequestHeaders(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n"); + ok(HttpAddRequestHeaders(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n"); + + ok(InternetCloseHandle(hRequest), "Close request handle failed\n"); + ok(InternetCloseHandle(hConnect), "Close connect handle failed\n"); + ok(InternetCloseHandle(hSession), "Close session handle failed\n"); +} + + + START_TEST(http) { InternetReadFile_test(INTERNET_FLAG_ASYNC); @@ -1128,4 +1157,5 @@ START_TEST(http) InternetTimeToSystemTimeW_test(); InternetCreateUrlA_test(); HttpSendRequestEx_test(); + HttpHeaders_test(); } Index: wine/dlls/wininet/http.c diff -u -p wine/dlls/wininet/http.c:1.112 wine/dlls/wininet/http.c:1.113 --- wine/dlls/wininet/http.c:1.112 22 Nov 2005 14:53:30 -0000 +++ wine/dlls/wininet/http.c 22 Nov 2005 14:53:30 -0000 @@ -2692,7 +2692,8 @@ static BOOL HTTP_ProcessHeader(LPWININET else lphttpHdr->wFlags &= ~HDR_ISREQUEST;
- if (!lphttpHdr->lpszValue && (dwModifier & (HTTP_ADDHDR_FLAG_ADD|HTTP_ADDHDR_FLAG_ADD_IF_NEW))) + if (!lphttpHdr->lpszValue && (dwModifier & HTTP_ADDHDR_FLAG_ADD || + dwModifier & HTTP_ADDHDR_FLAG_ADD_IF_NEW)) { INT slen;
@@ -2718,7 +2719,8 @@ static BOOL HTTP_ProcessHeader(LPWININET } else if (lphttpHdr->lpszValue) { - if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE) + if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE || + dwModifier & HTTP_ADDHDR_FLAG_ADD) bSuccess = HTTP_ReplaceHeaderValue( lphttpHdr, value ); else if (dwModifier & COALESCEFLASG) {