Commit 70fb4ef5 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

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

parent f14b6afb
...@@ -230,6 +230,10 @@ static const object_vtbl_t request_vtbl = ...@@ -230,6 +230,10 @@ static const object_vtbl_t request_vtbl =
HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version,
LPCWSTR referrer, LPCWSTR *types, DWORD flags ) 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; request_t *request;
connect_t *connect; connect_t *connect;
HINTERNET hrequest = NULL; HINTERNET hrequest = NULL;
...@@ -264,9 +268,13 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o ...@@ -264,9 +268,13 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
request->connect = connect; request->connect = connect;
list_add_head( &connect->hdr.children, &request->hdr.entry ); list_add_head( &connect->hdr.children, &request->hdr.entry );
if (verb && !(request->verb = strdupW( verb ))) goto end; if (!verb) verb = get;
if (object && !(request->path = strdupW( object ))) goto end; if (!object) object = slash;
if (version && !(request->version = strdupW( version ))) goto end; 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; if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
request->hdr.handle = hrequest; request->hdr.handle = hrequest;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <windef.h> #include <windef.h>
...@@ -277,7 +278,7 @@ static void test_WinHttpAddHeaders(void) ...@@ -277,7 +278,7 @@ static void test_WinHttpAddHeaders(void)
test_header_name, NULL, &len, &index); test_header_name, NULL, &len, &index);
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n"); 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(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"); ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header index.\n");
/* Try with a NULL buffer and a length thats too small */ /* Try with a NULL buffer and a length thats too small */
...@@ -289,7 +290,7 @@ static void test_WinHttpAddHeaders(void) ...@@ -289,7 +290,7 @@ static void test_WinHttpAddHeaders(void)
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n"); ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICENT_BUFFER, go %u\n", GetLastError()); "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"); ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header index.\n");
index = 0; index = 0;
...@@ -300,7 +301,7 @@ static void test_WinHttpAddHeaders(void) ...@@ -300,7 +301,7 @@ static void test_WinHttpAddHeaders(void)
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n"); ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError()); "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"); ok(index == 0, "WinHttpQueryHeaders failed: index was incremented.\n");
/* valid query */ /* valid query */
...@@ -314,13 +315,10 @@ static void test_WinHttpAddHeaders(void) ...@@ -314,13 +315,10 @@ static void test_WinHttpAddHeaders(void)
ok(len + sizeof(WCHAR) <= oldlen, "WinHttpQueryHeaders resulting length longer than advertized.\n"); 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 < 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"); 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, test_header_begin, sizeof(test_header_begin)) == 0, ok(memcmp(buffer + lstrlenW(buffer) - 4, test_header_end, sizeof(test_header_end)) == 0,
"WinHttpQueryHeaders returned invalid beginning of header string.\n"); "WinHttpQueryHeaders returned invalid end 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"); ok(index == 0, "WinHttpQueryHeaders incremented header index.\n");
/* tests for more indices */ /* tests for more indices */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment