From 13ba609b0488fa28fc03bcde1262e62a6eae2178 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Thu, 28 Aug 2008 13:51:41 +0200 Subject: [PATCH] winhttp: Use default values when empty strings are passed for verb, object and version parameters. --- dlls/winhttp/session.c | 6 +++--- dlls/winhttp/tests/winhttp.c | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c index dc8c1bfa9c3..9b66dccaef3 100644 --- a/dlls/winhttp/session.c +++ b/dlls/winhttp/session.c @@ -272,9 +272,9 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o if (!netconn_init( &request->netconn, request->hdr.flags & WINHTTP_FLAG_SECURE )) goto end; - if (!verb) verb = get; - if (!object) object = slash; - if (!version) version = http1_1; + if (!verb || !*verb) verb = get; + if (!object || !*object) object = slash; + if (!version || !*version) version = http1_1; if (!(request->verb = strdupW( verb ))) goto end; if (!(request->path = strdupW( object ))) goto end; diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index eb0129ceb53..6ba3a32a7fd 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -573,6 +573,45 @@ static void test_secure_connection(void) WinHttpCloseHandle(ses); } +static void test_request_parameter_defaults(void) +{ + static const WCHAR empty[] = {0}; + static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',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, codeweavers, 0, 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, NULL, 0, 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()); + + WinHttpCloseHandle(req); + + req = WinHttpOpenRequest(con, empty, empty, empty, NULL, NULL, 0); + ok(req != NULL, "failed to open a request %u\n", GetLastError()); + + ret = WinHttpSendRequest(req, NULL, 0, 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()); + + WinHttpCloseHandle(req); + WinHttpCloseHandle(con); + WinHttpCloseHandle(ses); +} + START_TEST (winhttp) { test_OpenRequest(); @@ -581,4 +620,5 @@ START_TEST (winhttp) test_WinHttpTimeToSystemTime(); test_WinHttpAddHeaders(); test_secure_connection(); + test_request_parameter_defaults(); }