Module: wine Branch: master Commit: 39b1dbed7a9f60f9a85be08d153926173019f7ef URL: http://source.winehq.org/git/wine.git/?a=commit;h=39b1dbed7a9f60f9a85be08d15...
Author: Hans Leidekker hans@codeweavers.com Date: Thu Oct 29 11:12:22 2009 +0100
winhttp: Accept empty headers parameter in WinHttpSendRequest.
---
dlls/winhttp/request.c | 1 + dlls/winhttp/tests/winhttp.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index ea0ecda..d504ea5 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -411,6 +411,7 @@ BOOL add_request_headers( request_t *request, LPCWSTR headers, DWORD len, DWORD header_t *header;
if (len == ~0u) len = strlenW( headers ); + if (!len) return TRUE; if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE; strcpyW( buffer, headers );
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index 24bdbb8..2f842f2 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -221,6 +221,30 @@ static void test_OpenRequest (void)
}
+static void test_empty_headers_param(void) +{ + static const WCHAR winehq[] = {'w','i','n','e','h','q','.','o','r','g',0}; + static const WCHAR empty[] = {0}; + HANDLE ses, con, req; + BOOL ret; + + ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0); + ok(ses != NULL, "failed to open session %u\n", GetLastError()); + + con = WinHttpConnect(ses, winehq, 80, 0); + ok(con != NULL, "failed to open a connection %u\n", GetLastError()); + + req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0); + ok(req != NULL, "failed to open a request %u\n", GetLastError()); + + ret = WinHttpSendRequest(req, empty, 0, NULL, 0, 0, 0); + ok(ret, "failed to send request %u\n", GetLastError()); + + WinHttpCloseHandle(req); + WinHttpCloseHandle(con); + WinHttpCloseHandle(ses); +} + static void test_SendRequest (void) { HINTERNET session, request, connection; @@ -978,4 +1002,5 @@ START_TEST (winhttp) test_request_parameter_defaults(); test_QueryOption(); test_set_default_proxy_config(); + test_empty_headers_param(); }