Author: akhaldi
Date: Sun Nov 22 10:13:49 2015
New Revision: 70008
URL:
http://svn.reactos.org/svn/reactos?rev=70008&view=rev
Log:
[WINHTTP_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536
Modified:
trunk/rostests/winetests/winhttp/notification.c
trunk/rostests/winetests/winhttp/url.c
trunk/rostests/winetests/winhttp/winhttp.c
Modified: trunk/rostests/winetests/winhttp/notification.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/notific…
==============================================================================
--- trunk/rostests/winetests/winhttp/notification.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/winhttp/notification.c [iso-8859-1] Sun Nov 22 10:13:49 2015
@@ -158,9 +158,9 @@
static void test_connection_cache( void )
{
- HANDLE ses, con, req;
- DWORD size, status;
- BOOL ret;
+ HANDLE ses, con, req, event;
+ DWORD size, status, err;
+ BOOL ret, unload = TRUE;
struct info info, *context = &info;
info.test = cache_test;
@@ -171,6 +171,14 @@
ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
ok(ses != NULL, "failed to open session %u\n", GetLastError());
+ event = CreateEventW( NULL, FALSE, FALSE, NULL );
+ ret = WinHttpSetOption( ses, WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT, &event,
sizeof(event) );
+ if (!ret)
+ {
+ win_skip("Unload event not supported\n");
+ unload = FALSE;
+ }
+
WinHttpSetStatusCallback( ses, check_notification,
WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context,
sizeof(struct info *) );
@@ -186,7 +194,8 @@
setup_test( &info, winhttp_send_request, __LINE__ );
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -214,7 +223,8 @@
setup_test( &info, winhttp_send_request, __LINE__ );
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -236,14 +246,32 @@
setup_test( &info, winhttp_close_handle, __LINE__ );
WinHttpCloseHandle( req );
WinHttpCloseHandle( con );
+
+ if (unload)
+ {
+ status = WaitForSingleObject( event, 0 );
+ ok(status == WAIT_TIMEOUT, "got %08x\n", status);
+ }
+
WinHttpCloseHandle( ses );
Sleep(2000); /* make sure connection is evicted from cache */
+ if (unload)
+ {
+ status = WaitForSingleObject( event, 0 );
+ ok(status == WAIT_OBJECT_0, "got %08x\n", status);
+ }
info.index = 0;
ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
ok(ses != NULL, "failed to open session %u\n", GetLastError());
+
+ if (unload)
+ {
+ ret = WinHttpSetOption( ses, WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT, &event,
sizeof(event) );
+ ok(ret, "failed to set unload option\n");
+ }
WinHttpSetStatusCallback( ses, check_notification,
WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
@@ -263,7 +291,8 @@
setup_test( &info, winhttp_send_request, __LINE__ );
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -291,7 +320,8 @@
setup_test( &info, winhttp_send_request, __LINE__ );
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -311,9 +341,23 @@
done:
WinHttpCloseHandle( req );
WinHttpCloseHandle( con );
+
+ if (unload)
+ {
+ status = WaitForSingleObject( event, 0 );
+ ok(status == WAIT_TIMEOUT, "got %08x\n", status);
+ }
+
WinHttpCloseHandle( ses );
Sleep(2000); /* make sure connection is evicted from cache */
+ if (unload)
+ {
+ status = WaitForSingleObject( event, 0 );
+ ok(status == WAIT_OBJECT_0, "got %08x\n", status);
+ }
+
+ CloseHandle( event );
}
static const struct notification redirect_test[] =
@@ -347,7 +391,7 @@
static void test_redirect( void )
{
HANDLE ses, con, req;
- DWORD size, status;
+ DWORD size, status, err;
BOOL ret;
struct info info, *context = &info;
@@ -374,7 +418,8 @@
setup_test( &info, winhttp_send_request, __LINE__ );
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -433,9 +478,9 @@
static void test_async( void )
{
- HANDLE ses, con, req;
- DWORD size, status;
- BOOL ret;
+ HANDLE ses, con, req, event;
+ DWORD size, status, err;
+ BOOL ret, unload = TRUE;
struct info info, *context = &info;
char buffer[1024];
@@ -447,22 +492,44 @@
ses = WinHttpOpen( user_agent, 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
ok(ses != NULL, "failed to open session %u\n", GetLastError());
+ event = CreateEventW( NULL, FALSE, FALSE, NULL );
+ ret = WinHttpSetOption( ses, WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT, &event,
sizeof(event) );
+ if (!ret)
+ {
+ win_skip("Unload event not supported\n");
+ unload = FALSE;
+ }
+
+ SetLastError( 0xdeadbeef );
WinHttpSetStatusCallback( ses, check_notification,
WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
-
+ err = GetLastError();
+ ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got
%u\n", err);
+
+ SetLastError( 0xdeadbeef );
ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context,
sizeof(struct info *) );
- ok(ret, "failed to set context value %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret, "failed to set context value %u\n", err);
+ ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got
%u\n", err);
setup_test( &info, winhttp_connect, __LINE__ );
+ SetLastError( 0xdeadbeef );
con = WinHttpConnect( ses, test_winehq, 0, 0 );
- ok(con != NULL, "failed to open a connection %u\n", GetLastError());
+ err = GetLastError();
+ ok(con != NULL, "failed to open a connection %u\n", err);
+ ok(err == ERROR_SUCCESS || broken(err == WSAEINVAL) /* < win7 */, "got
%u\n", err);
setup_test( &info, winhttp_open_request, __LINE__ );
+ SetLastError( 0xdeadbeef );
req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
- ok(req != NULL, "failed to open a request %u\n", GetLastError());
+ err = GetLastError();
+ ok(req != NULL, "failed to open a request %u\n", err);
+ ok(err == ERROR_SUCCESS, "got %u\n", err);
setup_test( &info, winhttp_send_request, __LINE__ );
+ SetLastError( 0xdeadbeef );
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
WinHttpCloseHandle( req );
@@ -471,39 +538,65 @@
CloseHandle( info.wait );
return;
}
- ok(ret, "failed to send request %u\n", GetLastError());
+ ok(ret, "failed to send request %u\n", err);
+ ok(err == ERROR_SUCCESS, "got %u\n", err);
WaitForSingleObject( info.wait, INFINITE );
setup_test( &info, winhttp_receive_response, __LINE__ );
+ SetLastError( 0xdeadbeef );
ret = WinHttpReceiveResponse( req, NULL );
- ok(ret, "failed to receive response %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret, "failed to receive response %u\n", err);
+ ok(err == ERROR_SUCCESS, "got %u\n", err);
WaitForSingleObject( info.wait, INFINITE );
size = sizeof(status);
+ SetLastError( 0xdeadbeef );
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE |
WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
- ok(ret, "failed unexpectedly %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret, "failed unexpectedly %u\n", err);
ok(status == 200, "request failed unexpectedly %u\n", status);
+ ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got
%u\n", err);
setup_test( &info, winhttp_query_data, __LINE__ );
+ SetLastError( 0xdeadbeef );
ret = WinHttpQueryDataAvailable( req, NULL );
- ok(ret, "failed to query data available %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret, "failed to query data available %u\n", err);
+ ok(err == ERROR_SUCCESS || err == ERROR_IO_PENDING || broken(err == 0xdeadbeef) /*
< win7 */, "got %u\n", err);
WaitForSingleObject( info.wait, INFINITE );
setup_test( &info, winhttp_read_data, __LINE__ );
+ SetLastError( 0xdeadbeef );
ret = WinHttpReadData( req, buffer, sizeof(buffer), NULL );
- ok(ret, "failed to query data available %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret, "failed to read data %u\n", err);
+ ok(err == ERROR_SUCCESS, "got %u\n", err);
WaitForSingleObject( info.wait, INFINITE );
setup_test( &info, winhttp_close_handle, __LINE__ );
WinHttpCloseHandle( req );
WinHttpCloseHandle( con );
+
+ if (unload)
+ {
+ status = WaitForSingleObject( event, 0 );
+ ok(status == WAIT_TIMEOUT, "got %08x\n", status);
+ }
WinHttpCloseHandle( ses );
WaitForSingleObject( info.wait, INFINITE );
+
+ if (unload)
+ {
+ status = WaitForSingleObject( event, 2000 );
+ ok(status == WAIT_OBJECT_0, "got %08x\n", status);
+ }
+ CloseHandle( event );
CloseHandle( info.wait );
}
Modified: trunk/rostests/winetests/winhttp/url.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/url.c?r…
==============================================================================
--- trunk/rostests/winetests/winhttp/url.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/winhttp/url.c [iso-8859-1] Sun Nov 22 10:13:49 2015
@@ -169,11 +169,14 @@
ok( len == 57, "expected len 57 got %u\n", len );
/* allocated url, NULL scheme */
+ SetLastError( 0xdeadbeef );
uc.lpszScheme = NULL;
url[0] = 0;
len = 256;
ret = WinHttpCreateUrl( &uc, 0, url, &len );
ok( ret, "expected success\n" );
+ ok( GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* <
win7 */,
+ "expected ERROR_SUCCESS got %u\n", GetLastError() );
ok( len == 56, "expected len 56 got %u\n", len );
ok( !lstrcmpW( url, url1 ), "url doesn't match\n" );
@@ -380,9 +383,13 @@
/* no buffers */
reset_url_components( &uc );
+ SetLastError( 0xdeadbeef );
ret = WinHttpCrackUrl( url_k1, 0, 0,&uc);
-
- ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
+ error = GetLastError();
+
+ ok( ret, "WinHttpCrackUrl failed le=%u\n", error );
+ ok( error == ERROR_SUCCESS || broken(error == ERROR_INVALID_PARAMETER) /* < win7
*/,
+ "got %u, expected ERROR_SUCCESS\n", error );
ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" );
ok( uc.lpszScheme == url_k1,"unexpected scheme\n" );
ok( uc.dwSchemeLength == 4, "unexpected scheme length\n" );
Modified: trunk/rostests/winetests/winhttp/winhttp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/winhttp…
==============================================================================
--- trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] Sun Nov 22 10:13:49 2015
@@ -2,6 +2,7 @@
* WinHTTP - tests
*
* Copyright 2008 Google (Zac Brown)
+ * Copyright 2015 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -26,6 +27,7 @@
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
+#include <winnls.h>
#include <ole2.h>
#include <winsock2.h>
//#include <ws2tcpip.h>
@@ -34,6 +36,7 @@
#include <winreg.h>
//#include "initguid.h"
#include <httprequest.h>
+#include <httprequestid.h>
#include <wine/test.h>
@@ -47,8 +50,11 @@
WINHTTP_PROXY_INFO proxy_info;
BOOL active = FALSE;
+ SetLastError(0xdeadbeef);
if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
{
+ ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /*
< win7 */,
+ "got %u\n", GetLastError());
active = (proxy_info.lpszProxy != NULL);
if (active)
GlobalFree(proxy_info.lpszProxy);
@@ -99,6 +105,8 @@
SetLastError(0xdeadbeef);
ret = WinHttpQueryOption(session, WINHTTP_OPTION_REDIRECT_POLICY, &feature,
&size);
ok(ret, "failed to query option %u\n", GetLastError());
+ ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* <
win7 */,
+ "got %u\n", GetLastError());
ok(size == sizeof(feature), "WinHttpQueryOption should set the size: %u\n",
size);
ok(feature == WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP,
"expected WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP, got
%#x\n", feature);
@@ -213,39 +221,57 @@
{
BOOL ret;
HINTERNET session, request, connection;
-
+ DWORD err;
+
+ SetLastError(0xdeadbeef);
session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
+ err = GetLastError();
ok(session != NULL, "WinHttpOpen failed to open session.\n");
+ ok(err == ERROR_SUCCESS, "got %u\n", err);
/* Test with a bad server name */
SetLastError(0xdeadbeef);
connection = WinHttpConnect(session, NULL, INTERNET_DEFAULT_HTTP_PORT, 0);
+ err = GetLastError();
ok (connection == NULL, "WinHttpConnect succeeded in opening connection to NULL
server argument.\n");
- ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER,
got %u.\n", GetLastError());
+ ok(err == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got
%u.\n", err);
/* Test with a valid server name */
+ SetLastError(0xdeadbeef);
connection = WinHttpConnect (session, test_winehq, INTERNET_DEFAULT_HTTP_PORT, 0);
- ok(connection != NULL, "WinHttpConnect failed to open a connection, error:
%u.\n", GetLastError());
-
+ err = GetLastError();
+ ok(connection != NULL, "WinHttpConnect failed to open a connection, error:
%u.\n", err);
+ ok(err == ERROR_SUCCESS || broken(err == WSAEINVAL) /* < win7 */, "got
%u\n", err);
+
+ SetLastError(0xdeadbeef);
request = WinHttpOpenRequest(connection, NULL, NULL, NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
- if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
+ err = GetLastError();
+ if (request == NULL && err == ERROR_WINHTTP_NAME_NOT_RESOLVED)
{
skip("Network unreachable, skipping.\n");
goto done;
}
- ok(request != NULL, "WinHttpOpenrequest failed to open a request, error:
%u.\n", GetLastError());
-
+ ok(request != NULL, "WinHttpOpenrequest failed to open a request, error:
%u.\n", err);
+ ok(err == ERROR_SUCCESS, "got %u\n", err);
+
+ SetLastError(0xdeadbeef);
ret = WinHttpSendRequest(request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, NULL, 0, 0, 0);
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("Connection failed, skipping.\n");
goto done;
}
- ok(ret == TRUE, "WinHttpSendRequest failed: %u\n", GetLastError());
+ ok(ret, "WinHttpSendRequest failed: %u\n", err);
+ ok(err == ERROR_SUCCESS, "got %u\n", err);
+
+ SetLastError(0xdeadbeef);
ret = WinHttpCloseHandle(request);
- ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n",
ret);
+ err = GetLastError();
+ ok(ret, "WinHttpCloseHandle failed on closing request, got %u.\n", err);
+ ok(err == ERROR_SUCCESS, "got %u\n", err);
done:
ret = WinHttpCloseHandle(connection);
@@ -259,6 +285,7 @@
{
static const WCHAR empty[] = {0};
HINTERNET ses, con, req;
+ DWORD err;
BOOL ret;
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
@@ -271,7 +298,8 @@
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSendRequest(req, empty, 0, NULL, 0, 0, 0);
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -294,7 +322,7 @@
static CHAR post_data[] = "mode=Test";
static const char test_post[] = "mode => Test\0\n";
HINTERNET session, request, connection;
- DWORD header_len, optional_len, total_len, bytes_rw, size;
+ DWORD header_len, optional_len, total_len, bytes_rw, size, err;
DWORD_PTR context;
BOOL ret;
CHAR buffer[256];
@@ -327,7 +355,8 @@
context++;
ret = WinHttpSendRequest(request, content_type, header_len, post_data, optional_len,
total_len, context);
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -343,9 +372,13 @@
for (i = 3; post_data[i]; i++)
{
bytes_rw = -1;
+ SetLastError(0xdeadbeef);
ret = WinHttpWriteData(request, &post_data[i], 1, &bytes_rw);
if (ret)
+ {
+ ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS got
%u.\n", GetLastError());
ok(bytes_rw == 1, "WinHttpWriteData failed, wrote %u bytes instead of 1
byte.\n", bytes_rw);
+ }
else /* Since we already passed all optional data in WinHttpSendRequest Win7
fails our WinHttpWriteData call */
{
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected
ERROR_INVALID_PARAMETER got %u.\n", GetLastError());
@@ -353,7 +386,10 @@
}
}
+ SetLastError(0xdeadbeef);
ret = WinHttpReceiveResponse(request, NULL);
+ ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == ERROR_NO_TOKEN) /*
< win7 */,
+ "Expected ERROR_SUCCESS got %u.\n", GetLastError());
ok(ret == TRUE, "WinHttpReceiveResponse failed: %u.\n", GetLastError());
bytes_rw = -1;
@@ -380,9 +416,25 @@
{'M','o','n',',','
','2','8',' ','J','u','l','
','2','0','0','8',' ',
'1','0',':','0','5',':','5','2','
','G','M','T',0};
WCHAR time_string[WINHTTP_TIME_FORMAT_BUFSIZE+1];
-
+ DWORD err;
+
+ SetLastError(0xdeadbeef);
+ ret = WinHttpTimeFromSystemTime(&time, NULL);
+ err = GetLastError();
+ ok(!ret, "WinHttpTimeFromSystemTime succeeded\n");
+ ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
+
+ SetLastError(0xdeadbeef);
+ ret = WinHttpTimeFromSystemTime(NULL, time_string);
+ err = GetLastError();
+ ok(!ret, "WinHttpTimeFromSystemTime succeeded\n");
+ ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
+
+ SetLastError(0xdeadbeef);
ret = WinHttpTimeFromSystemTime(&time, time_string);
- ok(ret == TRUE, "WinHttpTimeFromSystemTime failed: %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret, "WinHttpTimeFromSystemTime failed: %u\n", err);
+ ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got
%u\n", err);
ok(memcmp(time_string, expected_string, sizeof(expected_string)) == 0,
"Time string returned did not match expected time string.\n");
}
@@ -398,14 +450,33 @@
static const WCHAR time_string2[] =
{' ','m','o','n','
','2','8',' ','j','u','l','
','2','0','0','8',' ',
'1','0',' ','0','5','
','5','2','\n',0};
-
+ DWORD err;
+
+ SetLastError(0xdeadbeef);
+ ret = WinHttpTimeToSystemTime(time_string1, NULL);
+ err = GetLastError();
+ ok(!ret, "WinHttpTimeToSystemTime succeeded\n");
+ ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
+
+ SetLastError(0xdeadbeef);
+ ret = WinHttpTimeToSystemTime(NULL, &time);
+ err = GetLastError();
+ ok(!ret, "WinHttpTimeToSystemTime succeeded\n");
+ ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
+
+ SetLastError(0xdeadbeef);
ret = WinHttpTimeToSystemTime(time_string1, &time);
- ok(ret == TRUE, "WinHttpTimeToSystemTime failed: %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret, "WinHttpTimeToSystemTime failed: %u\n", err);
+ ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got
%u\n", err);
ok(memcmp(&time, &expected_time, sizeof(SYSTEMTIME)) == 0,
"Returned SYSTEMTIME structure did not match expected SYSTEMTIME
structure.\n");
+ SetLastError(0xdeadbeef);
ret = WinHttpTimeToSystemTime(time_string2, &time);
- ok(ret == TRUE, "WinHttpTimeToSystemTime failed: %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret, "WinHttpTimeToSystemTime failed: %u\n", err);
+ ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got
%u\n", err);
ok(memcmp(&time, &expected_time, sizeof(SYSTEMTIME)) == 0,
"Returned SYSTEMTIME structure did not match expected SYSTEMTIME
structure.\n");
}
@@ -423,7 +494,8 @@
static const WCHAR test_header_begin[] =
{'P','O','S','T','
','/','p','o','s','t','t','e','s','t','.','p','h','p','
','H','T','T','P','/','1'};
static const WCHAR full_path_test_header_begin[] =
- {'P','O','S','T','
','h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',':','8','0','/','p','o','s','t','.','p','h','p','
','H','T','T','P','/','1'};
+ {'P','O','S','T','
','h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',':','8','0',
+
'/','p','o','s','t','t','e','s','t','.','p','h','p','
','H','T','T','P','/','1'};
static const WCHAR test_header_end[] =
{'\r','\n','\r','\n',0};
static const WCHAR test_header_name[] =
{'W','a','r','n','i','n','g',0};
static const WCHAR test_header_name2[] =
{'n','a','m','e',0};
@@ -496,8 +568,11 @@
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM |
WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
test_header_name, buffer, &len, &index);
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded, found
'Warning' header.\n");
+ SetLastError(0xdeadbeef);
ret = WinHttpAddRequestHeaders(request, test_headers[0], -1L,
WINHTTP_ADDREQ_FLAG_ADD);
- ok(ret == TRUE, "WinHttpAddRequestHeader failed to add new header, got %d with
error %u.\n", ret, GetLastError());
+ err = GetLastError();
+ ok(ret, "WinHttpAddRequestHeader failed to add new header, got %d with error
%u.\n", ret, err);
+ ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got
%u\n", err);
index = 0;
len = sizeof(buffer);
@@ -901,7 +976,7 @@
static void test_secure_connection(void)
{
HINTERNET ses, con, req;
- DWORD size, status, policy, bitness, read_size;
+ DWORD size, status, policy, bitness, read_size, err;
BOOL ret;
CERT_CONTEXT *cert;
WINHTTP_CERTIFICATE_INFO info;
@@ -922,7 +997,8 @@
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("Connection failed, skipping.\n");
goto cleanup;
@@ -944,7 +1020,9 @@
WinHttpSetStatusCallback(req, cert_error, WINHTTP_CALLBACK_STATUS_SECURE_FAILURE,
0);
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
- if (!ret && (GetLastError() == ERROR_WINHTTP_SECURE_FAILURE || GetLastError()
== ERROR_WINHTTP_CANNOT_CONNECT))
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_SECURE_FAILURE || err ==
ERROR_WINHTTP_CANNOT_CONNECT ||
+ err == ERROR_WINHTTP_TIMEOUT))
{
skip("secure connection failed, skipping remaining secure tests\n");
goto cleanup;
@@ -1022,7 +1100,8 @@
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ error = GetLastError();
+ if (!ret && (error == ERROR_WINHTTP_CANNOT_CONNECT || error ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -1049,7 +1128,8 @@
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
- if (!ret && (GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT || GetLastError()
== ERROR_WINHTTP_TIMEOUT))
+ error = GetLastError();
+ if (!ret && (error == ERROR_WINHTTP_CANNOT_CONNECT || error ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -1216,9 +1296,11 @@
if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
skip("couldn't set default proxy configuration: access denied\n");
else
- ok(ret, "WinHttpSetDefaultProxyConfiguration failed: %d\n",
- GetLastError());
-
+ {
+ ok(ret, "WinHttpSetDefaultProxyConfiguration failed: %u\n",
GetLastError());
+ ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /*
< win7 */,
+ "got %u\n", GetLastError());
+ }
set_default_proxy_reg_value( saved_proxy_settings, len, type );
}
@@ -1254,6 +1336,8 @@
SetLastError(0xdeadbeef);
ret = WinHttpSetTimeouts(ses, -1, -1, -1, -1);
ok(ret, "%u\n", GetLastError());
+ ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* <
win7 */,
+ "expected ERROR_SUCCESS, got %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = WinHttpSetTimeouts(ses, 0, 0, 0, 0);
@@ -2060,12 +2144,15 @@
static void test_basic_request(int port, const WCHAR *verb, const WCHAR *path)
{
+ static const WCHAR test_header_end_clrf[] =
{'\r','\n','\r','\n',0};
+ static const WCHAR test_header_end_raw[] = {0,0};
HINTERNET ses, con, req;
char buffer[0x100];
+ WCHAR buffer2[0x100];
DWORD count, status, size, error, supported, first, target;
BOOL ret;
- ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
@@ -2095,6 +2182,21 @@
ok(supported == 0xdeadbeef, "got %x\n", supported);
ok(first == 0xdeadbeef, "got %x\n", first);
ok(target == 0xdeadbeef, "got %x\n", target);
+
+ size = sizeof(buffer2);
+ memset(buffer2, 0, sizeof(buffer2));
+ ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, buffer2,
&size, NULL);
+ ok(ret, "failed to query for raw headers: %u\n", GetLastError());
+ ok(!memcmp(buffer2 + lstrlenW(buffer2) - 4, test_header_end_clrf,
sizeof(test_header_end_clrf)),
+ "WinHttpQueryHeaders returned invalid end of header string\n");
+
+ size = sizeof(buffer2);
+ memset(buffer2, 0, sizeof(buffer2));
+ ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS, NULL, buffer2, &size,
NULL);
+ ok(ret, "failed to query for raw headers: %u\n", GetLastError());
+ ok(!memcmp(buffer2 + (size / sizeof(WCHAR)) - 1, test_header_end_raw,
sizeof(test_header_end_raw)),
+ "WinHttpQueryHeaders returned invalid end of header string\n");
+ ok(buffer2[(size / sizeof(WCHAR)) - 2] != 0, "returned string has too many NULL
characters\n");
count = 0;
memset(buffer, 0, sizeof(buffer));
@@ -2118,7 +2220,7 @@
DWORD status, size, error, supported, first, target;
BOOL ret;
- ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
@@ -2189,14 +2291,20 @@
ok(status == 401, "request failed unexpectedly %u\n", status);
supported = first = target = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
- ok(ret, "failed to query authentication schemes %u\n", GetLastError());
+ error = GetLastError();
+ ok(ret, "failed to query authentication schemes %u\n", error);
+ ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */,
"expected ERROR_SUCCESS, got %u\n", error);
ok(supported == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", supported);
ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", first);
ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %x\n", target);
+ SetLastError(0xdeadbeef);
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER,
WINHTTP_AUTH_SCHEME_NTLM, NULL, NULL, NULL);
- ok(ret, "failed to set credentials %u\n", GetLastError());
+ error = GetLastError();
+ ok(ret, "failed to set credentials %u\n", error);
+ ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */,
"expected ERROR_SUCCESS, got %u\n", error);
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER,
WINHTTP_AUTH_SCHEME_PASSPORT, NULL, NULL, NULL);
ok(ret, "failed to set credentials %u\n", GetLastError());
@@ -2249,7 +2357,7 @@
/* credentials set with WinHttpSetCredentials take precedence over those set through
options */
- ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
@@ -2283,7 +2391,7 @@
WinHttpCloseHandle(con);
WinHttpCloseHandle(ses);
- ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
@@ -2325,7 +2433,7 @@
DWORD error;
BOOL ret;
- ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
@@ -2362,7 +2470,7 @@
DWORD size, len = sizeof(buf), bytes_read, status;
BOOL ret;
- ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
@@ -2401,18 +2509,23 @@
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_CONTENT_LENGTH |
WINHTTP_QUERY_FLAG_NUMBER,
NULL, &status, &size, 0);
ok(!ret, "expected no content-length header\n");
- ok(GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND,
- "wrong error %u\n", GetLastError() );
+ ok(GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, "wrong error %u\n",
GetLastError());
ok(status == 12345, "expected 0, got %d\n", status);
+ SetLastError(0xdeadbeef);
size = 12345;
ret = WinHttpQueryDataAvailable(req, &size);
ok(ret, "expected success\n");
- ok(size == 0, "expected 0, got %d\n", size);
-
+ ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* <
win7 */,
+ "wrong error %u\n", GetLastError());
+ ok(!size, "expected 0, got %u\n", size);
+
+ SetLastError(0xdeadbeef);
ret = WinHttpReadData(req, buf, len, &bytes_read);
ok(ret, "expected success\n");
- ok( bytes_read == 0, "expected 0, got %u available\n", bytes_read );
+ ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* <
win7 */,
+ "wrong error %u\n", GetLastError());
+ ok(!bytes_read, "expected 0, got %u\n", bytes_read);
size = 12345;
ret = WinHttpQueryDataAvailable(req, &size);
@@ -2442,7 +2555,7 @@
DWORD size, len, count, status;
BOOL ret;
- ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
@@ -2507,7 +2620,7 @@
GetSystemTime(&st);
WinHttpTimeFromSystemTime(&st, &today[sizeof(ifmodifiedW)/sizeof(WCHAR)]);
- session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
+ session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY,
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
ok(session != NULL, "WinHttpOpen failed: %u\n", GetLastError());
@@ -2561,7 +2674,7 @@
DWORD index, len;
BOOL ret;
- ses = WinHttpOpen( test_useragent, 0, NULL, NULL, 0 );
+ ses = WinHttpOpen( test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
con = WinHttpConnect( ses, localhostW, port, 0 );
@@ -2593,7 +2706,7 @@
DWORD total_len = 0;
BOOL ret;
- ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
@@ -2646,7 +2759,7 @@
DWORD status, size;
BOOL ret;
- ses = WinHttpOpen( test_useragent, 0, NULL, NULL, 0 );
+ ses = WinHttpOpen( test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
con = WinHttpConnect( ses, localhostW, port, 0 );
@@ -2726,7 +2839,7 @@
WinHttpCloseHandle( con );
WinHttpCloseHandle( ses );
- ses = WinHttpOpen( test_useragent, 0, NULL, NULL, 0 );
+ ses = WinHttpOpen( test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
con = WinHttpConnect( ses, localhostW, port, 0 );
@@ -2760,7 +2873,7 @@
DWORD size, error;
BOOL ret;
- ses = WinHttpOpen( test_useragent, 0, NULL, NULL, 0 );
+ ses = WinHttpOpen( test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
con = WinHttpConnect( ses, localhostW, port, 0 );
@@ -2948,11 +3061,12 @@
static const WCHAR connectionW[] =
{'C','o','n','n','e','c','t','i','o','n',0};
static const WCHAR dateW[] = {'D','a','t','e',0};
static const WCHAR test_dataW[] =
{'t','e','s','t','d','a','t','a',128,0};
+ static const WCHAR utf8W[] =
{'u','t','f','-','8',0};
HRESULT hr;
IWinHttpRequest *req;
BSTR method, url, username, password, response = NULL, status_text = NULL, headers =
NULL;
BSTR date, today, connection, value = NULL;
- VARIANT async, empty, timeout, body, body2, proxy_server, bypass_list, data;
+ VARIANT async, empty, timeout, body, body2, proxy_server, bypass_list, data, cp;
VARIANT_BOOL succeeded;
LONG status;
WCHAR todayW[WINHTTP_TIME_FORMAT_BUFSIZE];
@@ -3035,6 +3149,39 @@
V_ERROR( &async ) = DISP_E_PARAMNOTFOUND;
hr = IWinHttpRequest_Open( req, method, url, async );
ok( hr == S_OK, "got %08x\n", hr );
+
+ V_VT( &cp ) = VT_ERROR;
+ V_ERROR( &cp ) = 0xdeadbeef;
+ hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
+ ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
+
+ V_VT( &cp ) = VT_UI4;
+ V_UI4( &cp ) = CP_ACP;
+ hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ V_VT( &cp ) = VT_ERROR;
+ V_ERROR( &cp ) = 0xdeadbeef;
+ hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
+ ok( V_I4( &cp ) == CP_ACP, "got %u\n", V_I4( &cp ) );
+
+ value = SysAllocString( utf8W );
+ V_VT( &cp ) = VT_BSTR;
+ V_BSTR( &cp ) = value;
+ hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+ SysFreeString( value );
+
+ V_VT( &cp ) = VT_ERROR;
+ V_ERROR( &cp ) = 0xdeadbeef;
+ hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
+ ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
hr = IWinHttpRequest_Abort( req );
ok( hr == S_OK, "got %08x\n", hr );
@@ -3407,6 +3554,241 @@
SysFreeString( today );
VariantClear( &proxy_server );
VariantClear( &bypass_list );
+ CoUninitialize();
+}
+
+static void request_get_property(IWinHttpRequest *request, int property, VARIANT *ret)
+{
+ DISPPARAMS params;
+ VARIANT arg;
+ HRESULT hr;
+
+ memset(¶ms, 0, sizeof(params));
+ params.cNamedArgs = 0;
+ params.rgdispidNamedArgs = NULL;
+ params.cArgs = 1;
+ params.rgvarg = &arg;
+ VariantInit(&arg);
+ V_VT(&arg) = VT_I4;
+ V_I4(&arg) = property;
+ VariantInit(ret);
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
+ DISPATCH_PROPERTYGET, ¶ms, ret, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+}
+
+static void test_IWinHttpRequest_Invoke(void)
+{
+ static const WCHAR utf8W[] =
{'U','T','F','-','8',0};
+ static const WCHAR regid[] =
{'W','i','n','H','t','t','p','.','W','i','n','H','t','t','p','R','e','q','u','e','s','t','.','5','.','1',0};
+ WCHAR openW[] = {'O','p','e','n',0};
+ WCHAR optionW[] =
{'O','p','t','i','o','n',0};
+ OLECHAR *open = openW, *option = optionW;
+ BSTR utf8;
+ CLSID clsid;
+ IWinHttpRequest *request;
+ IDispatch *dispatch;
+ DISPID id;
+ DISPPARAMS params;
+ VARIANT arg[3], ret;
+ UINT err;
+ BOOL bret;
+ HRESULT hr;
+
+ CoInitialize(NULL);
+
+ hr = CLSIDFromProgID(regid, &clsid);
+ ok(hr == S_OK, "CLSIDFromProgID error %#x\n", hr);
+ bret = IsEqualIID(&clsid, &CLSID_WinHttpRequest);
+ ok(bret || broken(!bret) /* win2003 */, "not expected %s\n",
wine_dbgstr_guid(&clsid));
+
+ hr = CoCreateInstance(&CLSID_WinHttpRequest, 0, CLSCTX_INPROC_SERVER,
&IID_IUnknown, (void **)&request);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ hr = IWinHttpRequest_QueryInterface(request, &IID_IDispatch, (void
**)&dispatch);
+ ok(hr == S_OK, "error %#x\n", hr);
+ IDispatch_Release(dispatch);
+
+ hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &open, 1, 0x0409,
&id);
+ ok(hr == S_OK, "error %#x\n", hr);
+ ok(id == DISPID_HTTPREQUEST_OPEN, "expected DISPID_HTTPREQUEST_OPEN, got
%u\n", id);
+
+ hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &option, 1, 0x0409,
&id);
+ ok(hr == S_OK, "error %#x\n", hr);
+ ok(id == DISPID_HTTPREQUEST_OPTION, "expected DISPID_HTTPREQUEST_OPTION, got
%u\n", id);
+
+ request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n",
V_I4(&ret));
+
+ memset(¶ms, 0, sizeof(params));
+ params.cArgs = 2;
+ params.cNamedArgs = 0;
+ params.rgvarg = arg;
+ V_VT(&arg[0]) = VT_I4;
+ V_I4(&arg[0]) = 1252;
+ V_VT(&arg[1]) = VT_R8;
+ V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
+ VariantInit(&ret);
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
+ DISPATCH_METHOD, ¶ms, NULL, NULL, &err);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n",
V_I4(&ret));
+
+ memset(¶ms, 0, sizeof(params));
+ params.cArgs = 2;
+ params.cNamedArgs = 0;
+ params.rgvarg = arg;
+ V_VT(&arg[0]) = VT_I4;
+ V_I4(&arg[0]) = 1252;
+ V_VT(&arg[1]) = VT_R8;
+ V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
+ VariantInit(&ret);
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
+ DISPATCH_METHOD | DISPATCH_PROPERTYPUT, ¶ms,
NULL, NULL, &err);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n",
V_I4(&ret));
+
+ memset(¶ms, 0, sizeof(params));
+ params.cArgs = 2;
+ params.cNamedArgs = 0;
+ params.rgvarg = arg;
+ V_VT(&arg[0]) = VT_I4;
+ V_I4(&arg[0]) = 1252;
+ V_VT(&arg[1]) = VT_R8;
+ V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
+ VariantInit(&ret);
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
+ DISPATCH_PROPERTYPUT, ¶ms, NULL, NULL,
&err);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
+
+ memset(¶ms, 0, sizeof(params));
+ params.cArgs = 2;
+ params.cNamedArgs = 0;
+ params.rgvarg = arg;
+ V_VT(&arg[0]) = VT_BSTR;
+ utf8 = SysAllocString(utf8W);
+ V_BSTR(&arg[0]) = utf8;
+ V_VT(&arg[1]) = VT_R8;
+ V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
+ hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD,
¶ms, NULL, NULL, &err);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
+
+ VariantInit(&ret);
+ hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD,
¶ms, &ret, NULL, &err);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
+
+ VariantInit(&ret);
+ hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_PROPERTYPUT,
¶ms, &ret, NULL, &err);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n",
V_I4(&ret));
+
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYPUT, ¶ms, NULL, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ hr = IWinHttpRequest_Invoke(request, 255, &IID_NULL, 0, DISPATCH_PROPERTYPUT,
¶ms, NULL, NULL, NULL);
+ ok(hr == DISP_E_MEMBERNOTFOUND, "error %#x\n", hr);
+
+ VariantInit(&ret);
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0,
DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, &err);
+ ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr);
+
+ VariantInit(&ret);
+if (0) /* crashes */
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYPUT, NULL, &ret, NULL, &err);
+
+ params.cArgs = 1;
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, &err);
+ ok(hr == DISP_E_TYPEMISMATCH, "error %#x\n", hr);
+
+ VariantInit(&arg[2]);
+ params.cArgs = 3;
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, &err);
+todo_wine
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ VariantInit(&arg[0]);
+ VariantInit(&arg[1]);
+ VariantInit(&arg[2]);
+
+ params.cArgs = 1;
+ V_VT(&arg[0]) = VT_I4;
+ V_I4(&arg[0]) = WinHttpRequestOption_URLCodePage;
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ V_VT(&ret) = 0xdead;
+ V_I4(&ret) = 0xbeef;
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_METHOD|DISPATCH_PROPERTYGET, ¶ms, &ret, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n",
V_I4(&ret));
+
+ V_VT(&ret) = 0xdead;
+ V_I4(&ret) = 0xbeef;
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_METHOD, ¶ms, &ret, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+ ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
+ ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n",
V_I4(&ret));
+
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_METHOD|DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ V_VT(&ret) = 0xdead;
+ V_I4(&ret) = 0xbeef;
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0,
¶ms, &ret, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+ ok(V_VT(&ret) == VT_EMPTY, "expected VT_EMPTY, got %d\n",
V_VT(&ret));
+ ok(V_I4(&ret) == 0xbeef || V_I4(&ret) == 0 /* Win8 */, "expected 0xdead,
got %d\n", V_I4(&ret));
+
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0,
¶ms, NULL, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0,
DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
+ ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr);
+
+ params.cArgs = 2;
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ params.cArgs = 0;
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
+ ok(hr == DISP_E_PARAMNOTFOUND, "error %#x\n", hr);
+
+ SysFreeString(utf8);
+
+ params.cArgs = 1;
+ V_VT(&arg[0]) = VT_I4;
+ V_I4(&arg[0]) = AutoLogonPolicy_Never;
+ VariantInit(&ret);
+ hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_SETAUTOLOGONPOLICY,
&IID_NULL, 0,
+ DISPATCH_METHOD, ¶ms, &ret, NULL, NULL);
+ ok(hr == S_OK, "error %#x\n", hr);
+
+ IWinHttpRequest_Release(request);
+
CoUninitialize();
}
@@ -3465,6 +3847,7 @@
}
else
{
+ ok( error == ERROR_SUCCESS, "got %u\n", error );
trace("%s\n", wine_dbgstr_w(url));
GlobalFree( url );
}
@@ -3484,8 +3867,12 @@
ok( !ret, "expected failure\n" );
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+ SetLastError(0xdeadbeef);
ret = WinHttpGetIEProxyConfigForCurrentUser( &cfg );
+ error = GetLastError();
ok( ret, "expected success\n" );
+ ok( error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* < win7 */,
"got %u\n", error );
+
trace("IEProxy.AutoDetect=%d\n", cfg.fAutoDetect);
trace("IEProxy.AutoConfigUrl=%s\n", wine_dbgstr_w(cfg.lpszAutoConfigUrl));
trace("IEProxy.Proxy=%s\n", wine_dbgstr_w(cfg.lpszProxy));
@@ -3572,9 +3959,12 @@
options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DNS_A;
memset( &info, 0, sizeof(info) );
+ SetLastError(0xdeadbeef);
ret = WinHttpGetProxyForUrl( session, urlW, &options, &info );
+ error = GetLastError();
if (ret)
{
+ ok( error == ERROR_SUCCESS, "got %u\n", error );
trace("Proxy.AccessType=%u\n", info.dwAccessType);
trace("Proxy.Proxy=%s\n", wine_dbgstr_w(info.lpszProxy));
trace("Proxy.ProxyBypass=%s\n", wine_dbgstr_w(info.lpszProxyBypass));
@@ -3604,7 +3994,7 @@
static const WCHAR verb[] =
{'/','t','e','s','t','c','h','u','n','k','e','d',0};
static const WCHAR chunked[] =
{'c','h','u','n','k','e','d',0};
WCHAR header[32];
- DWORD len;
+ DWORD len, err;
HINTERNET ses, con = NULL, req = NULL;
BOOL ret;
@@ -3623,7 +4013,8 @@
if (!req) goto done;
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
- if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
+ err = GetLastError();
+ if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err ==
ERROR_WINHTTP_TIMEOUT))
{
skip("connection failed, skipping\n");
goto done;
@@ -3702,6 +4093,7 @@
test_resolve_timeout();
test_credentials();
test_IWinHttpRequest();
+ test_IWinHttpRequest_Invoke();
test_WinHttpDetectAutoProxyConfigUrl();
test_WinHttpGetIEProxyConfigForCurrentUser();
test_WinHttpGetProxyForUrl();