diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 946168786ae..a6c16d7b653 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -378,14 +378,17 @@ DWORD add_request_headers( struct request *request, const WCHAR *headers, DWORD q[0] = '\r'; q[1] = '\n'; } - if (q[0] == '\r' && q[1] == '\n') break; + if (q[0] == '\r') break; q++; } if (!*p) break; if (*q == '\r') { *q = 0; - q += 2; /* jump over \r\n */ + if (q[1] == '\n') + q += 2; /* jump over \r\n */ + else + q++; /* jump over \r */ } if ((header = parse_header( p ))) { diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index 56f35252615..60204f6536f 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -3480,7 +3480,7 @@ static void test_bad_header( int port ) req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 ); ok( req != NULL, "failed to open a request %u\n", GetLastError() ); - ret = WinHttpAddRequestHeaders( req, L"Content-Type: text/html\n\r", ~0u, WINHTTP_ADDREQ_FLAG_ADD ); + ret = WinHttpAddRequestHeaders( req, L"Content-Type: text/html\n\rContent-Length:6\rCookie:111", ~0u, WINHTTP_ADDREQ_FLAG_ADD ); ok( ret, "failed to add header %u\n", GetLastError() ); index = 0; @@ -3492,6 +3492,15 @@ static void test_bad_header( int port ) ok( !lstrcmpW( buffer, L"text/html" ), "got %s\n", wine_dbgstr_w(buffer) ); ok( index == 1, "index = %u\n", index ); + index = 0; + buffer[0] = 0; + len = sizeof(buffer); + ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_CUSTOM|WINHTTP_QUERY_FLAG_REQUEST_HEADERS, + L"Cookie", buffer, &len, &index ); + ok( ret, "failed to query headers %u\n", GetLastError() ); + ok( !lstrcmpW( buffer, L"111" ), "got %s\n", wine_dbgstr_w(buffer) ); + ok( index == 1, "index = %u\n", index ); + WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); WinHttpCloseHandle( ses );