From 9e68c651d6c539d0b38c3f02c7cfdaad0701b57a Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Tue, 22 Nov 2005 14:53:30 +0000 Subject: [PATCH] Fix some logic to allow HTTP_ADDREQ_FLAG_ADD to replace existing headers. Also adding a test for some header adding flags. --- dlls/wininet/http.c | 6 ++++-- dlls/wininet/tests/http.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 31b0fd439c0..c2ba1a7fd6e 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2692,7 +2692,8 @@ static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v 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(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v } 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) { diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index babebafaa2c..3556fd12930 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -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\n"); + 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(); }