From 7e121e48714d376bbbd37dc5d1e9b085dcdcce09 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 24 Jun 2015 14:17:31 +0200 Subject: [PATCH] winhttp: Coalesce cookie headers. --- dlls/winhttp/cookie.c | 3 ++- dlls/winhttp/tests/winhttp.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/dlls/winhttp/cookie.c b/dlls/winhttp/cookie.c index 4bf08085589..d6dd4981469 100644 --- a/dlls/winhttp/cookie.c +++ b/dlls/winhttp/cookie.c @@ -270,7 +270,8 @@ BOOL add_cookie_headers( request_t *request ) } TRACE("%s\n", debugstr_w(header)); - add_request_headers( request, header, len, WINHTTP_ADDREQ_FLAG_ADD ); + add_request_headers( request, header, len, + WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON ); heap_free( header ); } } diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index 30115ef4c7b..2cf60b70650 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -2014,6 +2014,11 @@ static DWORD CALLBACK server_thread(LPVOID param) send(c, headmsg, sizeof headmsg - 1, 0); continue; } + if (strstr(buffer, "GET /cookie3")) + { + if (strstr(buffer, "Cookie: name=value2; name=value\r\n")) send(c, okmsg, sizeof(okmsg) - 1, 0); + else send(c, notokmsg, sizeof(notokmsg) - 1, 0); + } if (strstr(buffer, "GET /cookie2")) { if (strstr(buffer, "Cookie: name=value\r\n")) send(c, okmsg, sizeof(okmsg) - 1, 0); @@ -2621,6 +2626,9 @@ static void test_cookies( int port ) { static const WCHAR cookieW[] = {'/','c','o','o','k','i','e',0}; static const WCHAR cookie2W[] = {'/','c','o','o','k','i','e','2',0}; + static const WCHAR cookie3W[] = {'/','c','o','o','k','i','e','3',0}; + static const WCHAR cookieheaderW[] = + {'C','o','o','k','i','e',':',' ','n','a','m','e','=','v','a','l','u','e','2','\r','\n',0}; HINTERNET ses, con, req; DWORD status, size; BOOL ret; @@ -2684,6 +2692,23 @@ static void test_cookies( int port ) ok( ret, "failed to query status code %u\n", GetLastError() ); ok( status == 200, "request failed unexpectedly %u\n", status ); + WinHttpCloseHandle( req ); + + req = WinHttpOpenRequest( con, NULL, cookie3W, NULL, NULL, NULL, 0 ); + ok( req != NULL, "failed to open a request %u\n", GetLastError() ); + + ret = WinHttpSendRequest( req, cookieheaderW, ~0u, NULL, 0, 0, 0 ); + ok( ret, "failed to send request %u\n", GetLastError() ); + + ret = WinHttpReceiveResponse( req, NULL ); + ok( ret, "failed to receive response %u\n", GetLastError() ); + + status = 0xdeadbeef; + size = sizeof(status); + ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL ); + ok( ret, "failed to query status code %u\n", GetLastError() ); + ok( status == 200 || broken(status == 400), "request failed unexpectedly %u\n", status ); + WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); WinHttpCloseHandle( ses );