Hans Leidekker : winhttp: Use default values when empty strings are passed for verb, object and version parameters.

Alexandre Julliard julliard at winehq.org
Fri Aug 29 07:28:53 CDT 2008


Module: wine
Branch: master
Commit: 13ba609b0488fa28fc03bcde1262e62a6eae2178
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=13ba609b0488fa28fc03bcde1262e62a6eae2178

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu Aug 28 13:51:41 2008 +0200

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 dc8c1bf..9b66dcc 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 eb0129c..6ba3a32 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();
 }




More information about the wine-cvs mailing list