{
URL_COMPONENTS uc;
WCHAR *url;
- DWORD len;
+ DWORD len, err;
BOOL ret;
/* NULL components */
ok( !ret, "expected failure\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
- /* valid components, NULL url */
+ /* valid components, NULL url, insufficient length */
+ len = 0;
SetLastError( 0xdeadbeef );
ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
ok( !ret, "expected failure\n" );
- ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
- GetLastError() == ERROR_INVALID_PARAMETER,
- "expected ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
+ ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER got %u\n", GetLastError() );
+ ok( len == 57, "expected len 57 got %u\n", len );
+
+ /* valid components, NULL url, sufficient length */
+ SetLastError( 0xdeadbeef );
+ len = 256;
+ ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
+ err = GetLastError();
+ ok( !ret, "expected failure\n" );
+ ok( err == ERROR_INVALID_PARAMETER || broken(err == ERROR_INSUFFICIENT_BUFFER) /* < win7 */,
+ "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
+ ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %u\n", len );
/* correct size, NULL url */
fill_url_components( &uc );
SetLastError( 0xdeadbeef );
ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
+ err = GetLastError();
ok( !ret, "expected failure\n" );
- ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
- GetLastError() == ERROR_INVALID_PARAMETER,
- "expected ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
+ ok( err == ERROR_INVALID_PARAMETER || broken(err == ERROR_INSUFFICIENT_BUFFER) /* < win7 */,
+ "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
+ ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %u\n", len );
/* valid components, allocated url, short length */
SetLastError( 0xdeadbeef );
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSetOption(req, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, WINHTTP_NO_CLIENT_CERT_CONTEXT, 0);
- ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_STATE, "setting client cert context returned %x (%u)\n", ret, GetLastError());
+ err = GetLastError();
+ ok(!ret, "unexpected success\n");
+ ok(err == ERROR_WINHTTP_INCORRECT_HANDLE_STATE || broken(err == ERROR_INVALID_PARAMETER) /* winxp */,
+ "setting client cert context returned %u\n", err);
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
err = GetLastError();
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSetOption(req, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, WINHTTP_NO_CLIENT_CERT_CONTEXT, 0);
- ok(ret, "failed to set client cert context %u\n", GetLastError());
+ err = GetLastError();
+ ok(ret || broken(!ret && err == ERROR_INVALID_PARAMETER) /* winxp */, "failed to set client cert context %u\n", err);
WinHttpSetStatusCallback(req, cert_error, WINHTTP_CALLBACK_STATUS_SECURE_FAILURE, 0);
return ret;
}
-static void set_default_proxy_reg_value( BYTE *buf, DWORD len, DWORD type )
+static void set_proxy( REGSAM access, BYTE *buf, DWORD len, DWORD type )
{
- LONG l;
- HKEY key;
+ HKEY hkey;
+ if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, NULL, 0, access, NULL, &hkey, NULL ))
+ {
+ if (len) RegSetValueExW( hkey, WinHttpSettings, 0, type, buf, len );
+ else RegDeleteValueW( hkey, WinHttpSettings );
+ RegCloseKey( hkey );
+ }
+}
- l = RegCreateKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, NULL, 0,
- KEY_WRITE, NULL, &key, NULL );
- if (!l)
+static void set_default_proxy_reg_value( BYTE *buf, DWORD len, DWORD type )
+{
+ BOOL wow64;
+ IsWow64Process( GetCurrentProcess(), &wow64 );
+ if (sizeof(void *) > sizeof(int) || wow64)
{
- if (len)
- RegSetValueExW( key, WinHttpSettings, 0, type, buf, len );
- else
- RegDeleteValueW( key, WinHttpSettings );
- RegCloseKey( key );
+ set_proxy( KEY_WRITE|KEY_WOW64_64KEY, buf, len, type );
+ set_proxy( KEY_WRITE|KEY_WOW64_32KEY, buf, len, type );
}
+ else
+ set_proxy( KEY_WRITE, buf, len, type );
}
static void test_set_default_proxy_config(void)