Fix some logic to allow HTTP_ADDREQ_FLAG_ADD to replace existing

headers. Also adding a test for some header adding flags.
This commit is contained in:
Aric Stewart 2005-11-22 14:53:30 +00:00 committed by Alexandre Julliard
parent 7f9e281b72
commit 9e68c651d6
2 changed files with 35 additions and 3 deletions

View File

@ -2692,7 +2692,8 @@ static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v
else else
lphttpHdr->wFlags &= ~HDR_ISREQUEST; 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; INT slen;
@ -2718,7 +2719,8 @@ static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v
} }
else if (lphttpHdr->lpszValue) 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 ); bSuccess = HTTP_ReplaceHeaderValue( lphttpHdr, value );
else if (dwModifier & COALESCEFLASG) else if (dwModifier & COALESCEFLASG)
{ {

View File

@ -1114,6 +1114,35 @@ static void HttpSendRequestEx_test(void)
ok(InternetCloseHandle(hSession), "Close session 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) START_TEST(http)
{ {
InternetReadFile_test(INTERNET_FLAG_ASYNC); InternetReadFile_test(INTERNET_FLAG_ASYNC);
@ -1128,4 +1157,5 @@ START_TEST(http)
InternetTimeToSystemTimeW_test(); InternetTimeToSystemTimeW_test();
InternetCreateUrlA_test(); InternetCreateUrlA_test();
HttpSendRequestEx_test(); HttpSendRequestEx_test();
HttpHeaders_test();
} }