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

This commit is contained in:
Hans Leidekker 2008-08-28 13:51:41 +02:00 committed by Alexandre Julliard
parent f732065c4c
commit 13ba609b04
2 changed files with 43 additions and 3 deletions

View File

@ -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;

View File

@ -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();
}