Hans Leidekker : winhttp: Use default values for verb, object and version parameters in WinHttpOpenRequest.

Alexandre Julliard julliard at winehq.org
Wed Aug 20 08:13:58 CDT 2008


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Aug 20 11:37:17 2008 +0200

winhttp: Use default values for verb, object and version parameters in WinHttpOpenRequest.

---

 dlls/winhttp/session.c       |   14 +++++++++++---
 dlls/winhttp/tests/winhttp.c |   18 ++++++++----------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 01ab33d..d2bb340 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -230,6 +230,10 @@ static const object_vtbl_t request_vtbl =
 HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version,
                                      LPCWSTR referrer, LPCWSTR *types, DWORD flags )
 {
+    static const WCHAR get[] = {'G','E','T',0};
+    static const WCHAR slash[] = {'/',0};
+    static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
+
     request_t *request;
     connect_t *connect;
     HINTERNET hrequest = NULL;
@@ -264,9 +268,13 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
     request->connect = connect;
     list_add_head( &connect->hdr.children, &request->hdr.entry );
 
-    if (verb && !(request->verb = strdupW( verb ))) goto end;
-    if (object && !(request->path = strdupW( object ))) goto end;
-    if (version && !(request->version = strdupW( version ))) goto end;
+    if (!verb) verb = get;
+    if (!object) object = slash;
+    if (!version) version = http1_1;
+
+    if (!(request->verb = strdupW( verb ))) goto end;
+    if (!(request->path = strdupW( object ))) goto end;
+    if (!(request->version = strdupW( version ))) goto end;
 
     if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
     request->hdr.handle = hrequest;
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index 0fa89bd..4374056 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
+
 #include <stdarg.h>
 #include <stdlib.h>
 #include <windef.h>
@@ -277,7 +278,7 @@ static void test_WinHttpAddHeaders(void)
         test_header_name, NULL, &len, &index);
     ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
     todo_wine ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
-    todo_wine ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
+    ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
     ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header index.\n");
 
     /* Try with a NULL buffer and a length thats too small */
@@ -289,7 +290,7 @@ static void test_WinHttpAddHeaders(void)
     ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
         "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICENT_BUFFER, go %u\n", GetLastError());
-    todo_wine ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
+    ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
     ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header index.\n");
 
     index = 0;
@@ -300,7 +301,7 @@ static void test_WinHttpAddHeaders(void)
     ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
         "WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
-    todo_wine ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
+    ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
     ok(index == 0, "WinHttpQueryHeaders failed: index was incremented.\n");
 
     /* valid query */
@@ -314,13 +315,10 @@ static void test_WinHttpAddHeaders(void)
     ok(len + sizeof(WCHAR) <= oldlen, "WinHttpQueryHeaders resulting length longer than advertized.\n");
     ok((len < sizeof(buffer) - sizeof(WCHAR)) && buffer[len / sizeof(WCHAR)] == 0, "WinHttpQueryHeaders did not append NULL terminator\n");
     ok(len == lstrlenW(buffer) * sizeof(WCHAR), "WinHttpQueryHeaders returned incorrect length.\n");
-    todo_wine
-    {
-        ok(memcmp(buffer, test_header_begin, sizeof(test_header_begin)) == 0,
-            "WinHttpQueryHeaders returned invalid beginning of header string.\n");
-        ok(memcmp(buffer + lstrlenW(buffer) - 4, test_header_end, sizeof(test_header_end)) == 0,
-            "WinHttpQueryHeaders returned invalid end of header string.\n");
-    }
+    ok(memcmp(buffer, test_header_begin, sizeof(test_header_begin)) == 0,
+        "WinHttpQueryHeaders returned invalid beginning of header string.\n");
+    ok(memcmp(buffer + lstrlenW(buffer) - 4, test_header_end, sizeof(test_header_end)) == 0,
+        "WinHttpQueryHeaders returned invalid end of header string.\n");
     ok(index == 0, "WinHttpQueryHeaders incremented header index.\n");
 
     /* tests for more indices */




More information about the wine-cvs mailing list