mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-28 19:26:16 +00:00
[WINESYNC]
- Sync comdlg32, crypt32, gdiplus, inetcomm, jscript, msctf, mshtml, msxml3, rsaenh, schannel, shlwapi, urlmon, usp10, wininet winetests. svn path=/trunk/; revision=46982
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
|
||||
|
||||
static BOOL (WINAPI *pFtpCommandA)(HINTERNET,BOOL,DWORD,LPCSTR,DWORD_PTR,HINTERNET*);
|
||||
static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET,INTERNET_STATUS_CALLBACK);
|
||||
|
||||
|
||||
static void test_getfile_no_open(void)
|
||||
@@ -360,6 +361,20 @@ static void test_getfile(HINTERNET hFtp, HINTERNET hConnect)
|
||||
"Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
static void trace_extended_error(DWORD error)
|
||||
{
|
||||
DWORD code, buflen = 0;
|
||||
|
||||
if (error != ERROR_INTERNET_EXTENDED_ERROR) return;
|
||||
if (!InternetGetLastResponseInfoA(&code, NULL, &buflen) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
char *text = HeapAlloc(GetProcessHeap(), 0, ++buflen);
|
||||
InternetGetLastResponseInfoA(&code, text, &buflen);
|
||||
trace("%u %s\n", code, text);
|
||||
HeapFree(GetProcessHeap(), 0, text);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_openfile(HINTERNET hFtp, HINTERNET hConnect)
|
||||
{
|
||||
HINTERNET hOpenFile;
|
||||
@@ -414,34 +429,41 @@ static void test_openfile(HINTERNET hFtp, HINTERNET hConnect)
|
||||
if (hOpenFile)
|
||||
{
|
||||
BOOL bRet;
|
||||
DWORD error;
|
||||
HINTERNET hOpenFile2;
|
||||
HANDLE hFile;
|
||||
|
||||
/* We have a handle so all ftp calls should fail (TODO: Put all ftp-calls in here) */
|
||||
SetLastError(0xdeadbeef);
|
||||
bRet = FtpCreateDirectoryA(hFtp, "new_directory_deadbeef");
|
||||
error = GetLastError();
|
||||
ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
|
||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
|
||||
trace_extended_error(error);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
bRet = FtpDeleteFileA(hFtp, "non_existent_file_deadbeef");
|
||||
error = GetLastError();
|
||||
ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
|
||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
|
||||
trace_extended_error(error);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
|
||||
ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
|
||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||
error = GetLastError();
|
||||
ok ( bRet == FALSE || broken(bRet == TRUE), "Expected FtpGetFileA to fail\n");
|
||||
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_SUCCESS),
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
|
||||
DeleteFileA("should_be_non_existing_deadbeef"); /* Just in case */
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hOpenFile2 = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
||||
ok ( bRet == FALSE, "Expected FtpOpenFileA to fail\n");
|
||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||
error = GetLastError();
|
||||
ok ( bRet == FALSE || broken(bRet == TRUE), "Expected FtpOpenFileA to fail\n");
|
||||
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_SUCCESS),
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
|
||||
InternetCloseHandle(hOpenFile2); /* Just in case */
|
||||
|
||||
/* Create a temporary local file */
|
||||
@@ -451,22 +473,25 @@ static void test_openfile(HINTERNET hFtp, HINTERNET hConnect)
|
||||
CloseHandle(hFile);
|
||||
SetLastError(0xdeadbeef);
|
||||
bRet = FtpPutFileA(hFtp, "now_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
|
||||
error = GetLastError();
|
||||
ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
|
||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
|
||||
DeleteFileA("now_existing_local");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
bRet = FtpRemoveDirectoryA(hFtp, "should_be_non_existing_deadbeef_dir");
|
||||
error = GetLastError();
|
||||
ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
|
||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", "new");
|
||||
error = GetLastError();
|
||||
ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
|
||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error);
|
||||
}
|
||||
|
||||
InternetCloseHandle(hOpenFile);
|
||||
@@ -728,6 +753,7 @@ static void test_find_first_file(HINTERNET hFtp, HINTERNET hConnect)
|
||||
HINTERNET hSearch;
|
||||
HINTERNET hSearch2;
|
||||
HINTERNET hOpenFile;
|
||||
DWORD error;
|
||||
|
||||
/* NULL as the search file ought to return the first file in the directory */
|
||||
SetLastError(0xdeadbeef);
|
||||
@@ -773,10 +799,17 @@ static void test_find_first_file(HINTERNET hFtp, HINTERNET hConnect)
|
||||
/* This should fail as the OpenFile handle wasn't closed */
|
||||
SetLastError(0xdeadbeef);
|
||||
hSearch = FtpFindFirstFileA(hFtp, "welcome.msg", &findData, 0, 0);
|
||||
ok ( hSearch == NULL, "Expected FtpFindFirstFileA to fail\n" );
|
||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError() );
|
||||
InternetCloseHandle(hSearch); /* Just in case */
|
||||
error = GetLastError();
|
||||
ok ( hSearch == NULL || broken(hSearch != NULL), /* win2k */
|
||||
"Expected FtpFindFirstFileA to fail\n" );
|
||||
if (!hSearch)
|
||||
ok ( error == ERROR_FTP_TRANSFER_IN_PROGRESS || broken(error == ERROR_INTERNET_EXTENDED_ERROR),
|
||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", error );
|
||||
else
|
||||
{
|
||||
ok( error == ERROR_SUCCESS, "wrong error %u on success\n", GetLastError() );
|
||||
InternetCloseHandle(hSearch);
|
||||
}
|
||||
|
||||
InternetCloseHandle(hOpenFile);
|
||||
|
||||
@@ -889,6 +922,51 @@ static void test_get_current_dir(HINTERNET hFtp, HINTERNET hConnect)
|
||||
ok ( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
static void WINAPI status_callback(HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID info, DWORD info_len)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case INTERNET_STATUS_RESOLVING_NAME:
|
||||
case INTERNET_STATUS_NAME_RESOLVED:
|
||||
case INTERNET_STATUS_CONNECTING_TO_SERVER:
|
||||
case INTERNET_STATUS_CONNECTED_TO_SERVER:
|
||||
trace("%p %lx %u %s %u\n", handle, ctx, status, (char *)info, info_len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_status_callbacks(HINTERNET hInternet)
|
||||
{
|
||||
INTERNET_STATUS_CALLBACK cb;
|
||||
HINTERNET hFtp;
|
||||
BOOL ret;
|
||||
|
||||
if (!pInternetSetStatusCallbackA)
|
||||
{
|
||||
win_skip("InternetSetStatusCallbackA() is not available, skipping test\n");
|
||||
return;
|
||||
}
|
||||
|
||||
cb = pInternetSetStatusCallbackA(hInternet, status_callback);
|
||||
ok(cb == NULL, "expected NULL got %p\n", cb);
|
||||
|
||||
hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", NULL,
|
||||
INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 1);
|
||||
if (!hFtp)
|
||||
{
|
||||
skip("No ftp connection could be made to ftp.winehq.org %u\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
ret = InternetCloseHandle(hFtp);
|
||||
ok(ret, "InternetCloseHandle failed %u\n", GetLastError());
|
||||
|
||||
cb = pInternetSetStatusCallbackA(hInternet, NULL);
|
||||
ok(cb == status_callback, "expected check_status got %p\n", cb);
|
||||
}
|
||||
|
||||
START_TEST(ftp)
|
||||
{
|
||||
HMODULE hWininet;
|
||||
@@ -896,6 +974,7 @@ START_TEST(ftp)
|
||||
|
||||
hWininet = GetModuleHandleA("wininet.dll");
|
||||
pFtpCommandA = (void*)GetProcAddress(hWininet, "FtpCommandA");
|
||||
pInternetSetStatusCallbackA = (void*)GetProcAddress(hWininet, "InternetSetStatusCallbackA");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hInternet = InternetOpen("winetest", 0, NULL, NULL, 0);
|
||||
@@ -937,6 +1016,7 @@ START_TEST(ftp)
|
||||
test_command(hFtp, hHttp);
|
||||
test_find_first_file(hFtp, hHttp);
|
||||
test_get_current_dir(hFtp, hHttp);
|
||||
test_status_callbacks(hInternet);
|
||||
|
||||
InternetCloseHandle(hHttp);
|
||||
InternetCloseHandle(hFtp);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -105,6 +105,35 @@ static CHAR status_string[MAX_INTERNET_STATUS][MAX_STATUS_NAME];
|
||||
|
||||
static HANDLE hCompleteEvent;
|
||||
|
||||
#define TESTF_REDIRECT 0x01
|
||||
#define TESTF_COMPRESSED 0x02
|
||||
#define TESTF_ALLOW_COOKIE 0x04
|
||||
|
||||
typedef struct {
|
||||
const char *url;
|
||||
const char *redirected_url;
|
||||
const char *host;
|
||||
const char *path;
|
||||
DWORD flags;
|
||||
} test_data_t;
|
||||
|
||||
static const test_data_t test_data[] = {
|
||||
{
|
||||
"http://test.winehq.org/testredirect",
|
||||
"http://test.winehq.org/hello.html",
|
||||
"test.winehq.org",
|
||||
"/testredirect",
|
||||
TESTF_REDIRECT
|
||||
},
|
||||
{
|
||||
"http://www.codeweavers.com/",
|
||||
"http://www.codeweavers.com/",
|
||||
"www.codeweavers.com",
|
||||
"",
|
||||
TESTF_COMPRESSED|TESTF_ALLOW_COOKIE
|
||||
}
|
||||
};
|
||||
|
||||
static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET ,INTERNET_STATUS_CALLBACK);
|
||||
|
||||
|
||||
@@ -239,7 +268,7 @@ static VOID WINAPI callback(
|
||||
}
|
||||
}
|
||||
|
||||
static void InternetReadFile_test(int flags)
|
||||
static void InternetReadFile_test(int flags, const test_data_t *test)
|
||||
{
|
||||
BOOL res;
|
||||
CHAR buffer[4000];
|
||||
@@ -250,10 +279,11 @@ static void InternetReadFile_test(int flags)
|
||||
|
||||
hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
|
||||
trace("Starting InternetReadFile test with flags 0x%x\n",flags);
|
||||
trace("Starting InternetReadFile test with flags 0x%x on url %s\n",flags,test->url);
|
||||
|
||||
trace("InternetOpenA <--\n");
|
||||
hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags);
|
||||
hi = InternetOpenA((test->flags & TESTF_COMPRESSED) ? "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" : "",
|
||||
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags);
|
||||
ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
|
||||
trace("InternetOpenA -->\n");
|
||||
|
||||
@@ -264,7 +294,7 @@ static void InternetReadFile_test(int flags)
|
||||
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
|
||||
|
||||
trace("InternetConnectA <--\n");
|
||||
hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
|
||||
hic=InternetConnectA(hi, test->host, INTERNET_INVALID_PORT_NUMBER,
|
||||
NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
|
||||
ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
|
||||
trace("InternetConnectA -->\n");
|
||||
@@ -275,7 +305,7 @@ static void InternetReadFile_test(int flags)
|
||||
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
|
||||
|
||||
trace("HttpOpenRequestA <--\n");
|
||||
hor = HttpOpenRequestA(hic, "GET", "/testredirect", NULL, NULL, types,
|
||||
hor = HttpOpenRequestA(hic, "GET", test->path, NULL, NULL, types,
|
||||
INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE,
|
||||
0xdeadbead);
|
||||
if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
|
||||
@@ -295,7 +325,7 @@ static void InternetReadFile_test(int flags)
|
||||
length = sizeof(buffer);
|
||||
res = InternetQueryOptionA(hor, INTERNET_OPTION_URL, buffer, &length);
|
||||
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
|
||||
ok(!strcmp(buffer, "http://test.winehq.org/testredirect"), "Wrong URL %s\n", buffer);
|
||||
ok(!strcmp(buffer, test->url), "Wrong URL %s, expected %s\n", buffer, test->url);
|
||||
|
||||
length = sizeof(buffer);
|
||||
res = HttpQueryInfoA(hor, HTTP_QUERY_RAW_HEADERS, buffer, &length, 0x0);
|
||||
@@ -306,6 +336,10 @@ static void InternetReadFile_test(int flags)
|
||||
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
|
||||
CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
|
||||
CHECK_NOT_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED);
|
||||
if(test->flags & TESTF_ALLOW_COOKIE) {
|
||||
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
|
||||
SET_OPTIONAL(INTERNET_STATUS_COOKIE_RECEIVED);
|
||||
}
|
||||
if (first_connection_to_test_url)
|
||||
{
|
||||
SET_EXPECT(INTERNET_STATUS_RESOLVING_NAME);
|
||||
@@ -322,12 +356,14 @@ static void InternetReadFile_test(int flags)
|
||||
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
|
||||
SET_WINE_ALLOW(INTERNET_STATUS_CONNECTED_TO_SERVER);
|
||||
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
|
||||
SET_EXPECT2(INTERNET_STATUS_SENDING_REQUEST, 2);
|
||||
SET_EXPECT2(INTERNET_STATUS_REQUEST_SENT, 2);
|
||||
SET_EXPECT2(INTERNET_STATUS_RECEIVING_RESPONSE, 2);
|
||||
SET_EXPECT2(INTERNET_STATUS_RESPONSE_RECEIVED, 2);
|
||||
SET_OPTIONAL2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
|
||||
SET_OPTIONAL2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
|
||||
SET_EXPECT2(INTERNET_STATUS_SENDING_REQUEST, (test->flags & TESTF_REDIRECT) ? 2 : 1);
|
||||
SET_EXPECT2(INTERNET_STATUS_REQUEST_SENT, (test->flags & TESTF_REDIRECT) ? 2 : 1);
|
||||
SET_EXPECT2(INTERNET_STATUS_RECEIVING_RESPONSE, (test->flags & TESTF_REDIRECT) ? 2 : 1);
|
||||
SET_EXPECT2(INTERNET_STATUS_RESPONSE_RECEIVED, (test->flags & TESTF_REDIRECT) ? 2 : 1);
|
||||
if(test->flags & TESTF_REDIRECT) {
|
||||
SET_OPTIONAL2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
|
||||
SET_OPTIONAL2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
|
||||
}
|
||||
SET_EXPECT(INTERNET_STATUS_REDIRECT);
|
||||
SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER);
|
||||
SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER);
|
||||
@@ -336,9 +372,19 @@ static void InternetReadFile_test(int flags)
|
||||
else
|
||||
SET_WINE_ALLOW(INTERNET_STATUS_REQUEST_COMPLETE);
|
||||
|
||||
if(test->flags & TESTF_COMPRESSED) {
|
||||
BOOL b = TRUE;
|
||||
|
||||
res = InternetSetOption(hor, INTERNET_OPTION_HTTP_DECODING, &b, sizeof(b));
|
||||
ok(res || broken(!res && GetLastError() == ERROR_INTERNET_INVALID_OPTION),
|
||||
"InternetSetOption failed: %u\n", GetLastError());
|
||||
if(!res)
|
||||
goto abort;
|
||||
}
|
||||
|
||||
trace("HttpSendRequestA -->\n");
|
||||
SetLastError(0xdeadbeef);
|
||||
res = HttpSendRequestA(hor, "", -1, NULL, 0);
|
||||
res = HttpSendRequestA(hor, (test->flags & TESTF_COMPRESSED) ? "Accept-Encoding: gzip, deflate" : "", -1, NULL, 0);
|
||||
if (flags & INTERNET_FLAG_ASYNC)
|
||||
ok(!res && (GetLastError() == ERROR_IO_PENDING),
|
||||
"Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
|
||||
@@ -350,6 +396,10 @@ static void InternetReadFile_test(int flags)
|
||||
if (flags & INTERNET_FLAG_ASYNC)
|
||||
WaitForSingleObject(hCompleteEvent, INFINITE);
|
||||
|
||||
if(test->flags & TESTF_ALLOW_COOKIE) {
|
||||
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT);
|
||||
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_RECEIVED);
|
||||
}
|
||||
if (first_connection_to_test_url)
|
||||
{
|
||||
CHECK_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
|
||||
@@ -360,11 +410,12 @@ static void InternetReadFile_test(int flags)
|
||||
CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
|
||||
CHECK_NOT_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED);
|
||||
}
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_SENDING_REQUEST, 2);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_REQUEST_SENT, 2);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_RECEIVING_RESPONSE, 2);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_RESPONSE_RECEIVED, 2);
|
||||
CHECK_NOTIFIED(INTERNET_STATUS_REDIRECT);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_SENDING_REQUEST, (test->flags & TESTF_REDIRECT) ? 2 : 1);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_REQUEST_SENT, (test->flags & TESTF_REDIRECT) ? 2 : 1);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_RECEIVING_RESPONSE, (test->flags & TESTF_REDIRECT) ? 2 : 1);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_RESPONSE_RECEIVED, (test->flags & TESTF_REDIRECT) ? 2 : 1);
|
||||
if(test->flags & TESTF_REDIRECT)
|
||||
CHECK_NOTIFIED(INTERNET_STATUS_REDIRECT);
|
||||
if (flags & INTERNET_FLAG_ASYNC)
|
||||
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
|
||||
else
|
||||
@@ -389,16 +440,24 @@ static void InternetReadFile_test(int flags)
|
||||
length = sizeof(buffer);
|
||||
res = InternetQueryOptionA(hor, INTERNET_OPTION_URL, buffer, &length);
|
||||
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
|
||||
ok(!strcmp(buffer, "http://test.winehq.org/hello.html"), "Wrong URL %s\n", buffer);
|
||||
ok(!strcmp(buffer, test->redirected_url), "Wrong URL %s\n", buffer);
|
||||
|
||||
length = 16;
|
||||
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0);
|
||||
trace("Option 0x5 -> %i %s (%u)\n",res,buffer,GetLastError());
|
||||
trace("Option HTTP_QUERY_CONTENT_LENGTH -> %i %s (%u)\n",res,buffer,GetLastError());
|
||||
if(test->flags & TESTF_COMPRESSED)
|
||||
ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND,
|
||||
"expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%u)\n", res, GetLastError());
|
||||
|
||||
length = 100;
|
||||
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0);
|
||||
buffer[length]=0;
|
||||
trace("Option 0x1 -> %i %s\n",res,buffer);
|
||||
trace("Option HTTP_QUERY_CONTENT_TYPE -> %i %s\n",res,buffer);
|
||||
|
||||
length = 100;
|
||||
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_ENCODING,buffer,&length,0x0);
|
||||
buffer[length]=0;
|
||||
trace("Option HTTP_QUERY_CONTENT_ENCODING -> %i %s\n",res,buffer);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
res = InternetReadFile(NULL, buffer, 100, &length);
|
||||
@@ -447,8 +506,10 @@ static void InternetReadFile_test(int flags)
|
||||
if (length == 0)
|
||||
break;
|
||||
}
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
|
||||
if(test->flags & TESTF_REDIRECT) {
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
|
||||
CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
|
||||
}
|
||||
abort:
|
||||
trace("aborting\n");
|
||||
SET_EXPECT2(INTERNET_STATUS_HANDLE_CLOSING, (hor != 0x0) + (hic != 0x0));
|
||||
@@ -493,6 +554,114 @@ abort:
|
||||
first_connection_to_test_url = FALSE;
|
||||
}
|
||||
|
||||
static void InternetReadFile_chunked_test(void)
|
||||
{
|
||||
BOOL res;
|
||||
CHAR buffer[4000];
|
||||
DWORD length;
|
||||
const char *types[2] = { "*", NULL };
|
||||
HINTERNET hi, hic = 0, hor = 0;
|
||||
|
||||
trace("Starting InternetReadFile chunked test\n");
|
||||
|
||||
trace("InternetOpenA <--\n");
|
||||
hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
||||
ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
|
||||
trace("InternetOpenA -->\n");
|
||||
|
||||
if (hi == 0x0) goto abort;
|
||||
|
||||
trace("InternetConnectA <--\n");
|
||||
hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
|
||||
NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
|
||||
ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
|
||||
trace("InternetConnectA -->\n");
|
||||
|
||||
if (hic == 0x0) goto abort;
|
||||
|
||||
trace("HttpOpenRequestA <--\n");
|
||||
hor = HttpOpenRequestA(hic, "GET", "/testchunked", NULL, NULL, types,
|
||||
INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE,
|
||||
0xdeadbead);
|
||||
if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
|
||||
/*
|
||||
* If the internet name can't be resolved we are probably behind
|
||||
* a firewall or in some other way not directly connected to the
|
||||
* Internet. Not enough reason to fail the test. Just ignore and
|
||||
* abort.
|
||||
*/
|
||||
} else {
|
||||
ok((hor != 0x0),"HttpOpenRequest failed with error %u\n", GetLastError());
|
||||
}
|
||||
trace("HttpOpenRequestA -->\n");
|
||||
|
||||
if (hor == 0x0) goto abort;
|
||||
|
||||
trace("HttpSendRequestA -->\n");
|
||||
SetLastError(0xdeadbeef);
|
||||
res = HttpSendRequestA(hor, "", -1, NULL, 0);
|
||||
ok(res || (GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED),
|
||||
"Synchronous HttpSendRequest returning 0, error %u\n", GetLastError());
|
||||
trace("HttpSendRequestA <--\n");
|
||||
|
||||
length = 100;
|
||||
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0);
|
||||
buffer[length]=0;
|
||||
trace("Option CONTENT_TYPE -> %i %s\n",res,buffer);
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
length = 100;
|
||||
res = HttpQueryInfoA(hor,HTTP_QUERY_TRANSFER_ENCODING,buffer,&length,0x0);
|
||||
buffer[length]=0;
|
||||
trace("Option TRANSFER_ENCODING -> %i %s\n",res,buffer);
|
||||
ok( res, "Failed to get TRANSFER_ENCODING option, error %u\n", GetLastError() );
|
||||
ok( !strcmp( buffer, "chunked" ), "Wrong transfer encoding '%s'\n", buffer );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
length = 16;
|
||||
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0);
|
||||
ok( !res, "Found CONTENT_LENGTH option '%s'\n", buffer );
|
||||
ok( GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Wrong error %u\n", GetLastError() );
|
||||
|
||||
length = 100;
|
||||
trace("Entering Query loop\n");
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
|
||||
ok(!(!res && length != 0),"InternetQueryDataAvailable failed with non-zero length\n");
|
||||
ok(res, "InternetQueryDataAvailable failed, error %d\n", GetLastError());
|
||||
trace("got %u available\n",length);
|
||||
if (length)
|
||||
{
|
||||
DWORD got;
|
||||
char *buffer = HeapAlloc(GetProcessHeap(),0,length+1);
|
||||
|
||||
res = InternetReadFile(hor,buffer,length,&got);
|
||||
|
||||
buffer[got]=0;
|
||||
trace("ReadFile -> %i %i\n",res,got);
|
||||
ok( length == got, "only got %u of %u available\n", got, length );
|
||||
ok( buffer[got-1] == '\n', "received partial line '%s'\n", buffer );
|
||||
|
||||
HeapFree(GetProcessHeap(),0,buffer);
|
||||
if (!got) break;
|
||||
}
|
||||
if (length == 0)
|
||||
break;
|
||||
}
|
||||
abort:
|
||||
trace("aborting\n");
|
||||
if (hor != 0x0) {
|
||||
res = InternetCloseHandle(hor);
|
||||
ok (res, "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
|
||||
}
|
||||
if (hi != 0x0) {
|
||||
res = InternetCloseHandle(hi);
|
||||
ok (res, "InternetCloseHandle of handle opened by InternetOpenA failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void InternetReadFileExA_test(int flags)
|
||||
{
|
||||
DWORD rc;
|
||||
@@ -802,8 +971,7 @@ static void HttpSendRequestEx_test(void)
|
||||
HINTERNET hRequest;
|
||||
|
||||
INTERNET_BUFFERS BufferIn;
|
||||
DWORD dwBytesWritten;
|
||||
DWORD dwBytesRead;
|
||||
DWORD dwBytesWritten, dwBytesRead, error;
|
||||
CHAR szBuffer[256];
|
||||
int i;
|
||||
BOOL ret;
|
||||
@@ -839,8 +1007,11 @@ static void HttpSendRequestEx_test(void)
|
||||
BufferIn.dwOffsetLow = 0;
|
||||
BufferIn.dwOffsetHigh = 0;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = HttpSendRequestEx(hRequest, &BufferIn, NULL, 0 ,0);
|
||||
ok(ret, "HttpSendRequestEx Failed with error %u\n", GetLastError());
|
||||
error = GetLastError();
|
||||
ok(ret, "HttpSendRequestEx Failed with error %u\n", error);
|
||||
ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
|
||||
|
||||
for (i = 3; szPostData[i]; i++)
|
||||
ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
|
||||
@@ -942,7 +1113,7 @@ static void test_http_cache(void)
|
||||
|
||||
size = sizeof(url);
|
||||
ret = InternetQueryOptionA(request, INTERNET_OPTION_URL, url, &size);
|
||||
ok(ret, "InternetQueryOptionA(INTERNET_OPTION_url) failed: %u\n", GetLastError());
|
||||
ok(ret, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
|
||||
ok(!strcmp(url, "http://test.winehq.org/hello.html"), "Wrong URL %s\n", url);
|
||||
|
||||
size = sizeof(file_name);
|
||||
@@ -977,7 +1148,7 @@ static void test_http_cache(void)
|
||||
|
||||
file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
todo_wine ok(file != INVALID_HANDLE_VALUE, "CreateFile succeeded\n");
|
||||
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
|
||||
CloseHandle(file);
|
||||
|
||||
request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, types, INTERNET_FLAG_NO_CACHE_WRITE, 0);
|
||||
@@ -993,13 +1164,20 @@ static void test_http_cache(void)
|
||||
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
|
||||
|
||||
size = sizeof(file_name);
|
||||
file_name[0] = 0;
|
||||
ret = InternetQueryOptionA(request, INTERNET_OPTION_DATAFILE_NAME, file_name, &size);
|
||||
todo_wine ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed %u\n", GetLastError());
|
||||
|
||||
file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
if (ret)
|
||||
{
|
||||
file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
todo_wine ok(file != INVALID_HANDLE_VALUE, "CreateFile succeeded\n");
|
||||
CloseHandle(file);
|
||||
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
|
||||
CloseHandle(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* < IE8 */
|
||||
ok(file_name[0] == 0, "Didn't expect a file name\n");
|
||||
}
|
||||
|
||||
ok(InternetCloseHandle(request), "Close request handle failed\n");
|
||||
ok(InternetCloseHandle(connect), "Close connect handle failed\n");
|
||||
@@ -1284,15 +1462,47 @@ static void HttpHeaders_test(void)
|
||||
ok(index == 1, "Index was not incremented\n");
|
||||
ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
|
||||
|
||||
/* Ensure that malformed header separators are ignored and don't cause a failure */
|
||||
ok(HttpAddRequestHeaders(hRequest,"\r\rMalformedTest:value\n\nMalformedTestTwo: value2\rMalformedTestThree: value3\n\n\r\r\n",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE),
|
||||
"Failed to add header with malformed entries in list\n");
|
||||
|
||||
index = 0;
|
||||
len = sizeof(buffer);
|
||||
strcpy(buffer,"MalformedTest");
|
||||
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
|
||||
ok(index == 1, "Index was not incremented\n");
|
||||
ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
|
||||
index = 0;
|
||||
len = sizeof(buffer);
|
||||
strcpy(buffer,"MalformedTestTwo");
|
||||
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
|
||||
ok(index == 1, "Index was not incremented\n");
|
||||
ok(strcmp(buffer,"value2")==0, "incorrect string was returned(%s)\n",buffer);
|
||||
index = 0;
|
||||
len = sizeof(buffer);
|
||||
strcpy(buffer,"MalformedTestThree");
|
||||
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
|
||||
ok(index == 1, "Index was not incremented\n");
|
||||
ok(strcmp(buffer,"value3")==0, "incorrect string was returned(%s)\n",buffer);
|
||||
|
||||
ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
|
||||
done:
|
||||
ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
|
||||
ok(InternetCloseHandle(hSession), "Close session handle failed\n");
|
||||
}
|
||||
|
||||
static const char garbagemsg[] =
|
||||
"Garbage: Header\r\n";
|
||||
|
||||
static const char contmsg[] =
|
||||
"HTTP/1.1 100 Continue\r\n";
|
||||
|
||||
static const char expandcontmsg[] =
|
||||
"HTTP/1.1 100 Continue\r\n"
|
||||
"Server: winecontinue\r\n"
|
||||
"Tag: something witty\r\n"
|
||||
"\r\n";
|
||||
|
||||
static const char okmsg[] =
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: winetest\r\n"
|
||||
@@ -1518,6 +1728,19 @@ static DWORD CALLBACK server_thread(LPVOID param)
|
||||
send(c, page1, sizeof page1-1, 0);
|
||||
last_request = 1;
|
||||
}
|
||||
if (strstr(buffer, "GET /testF"))
|
||||
{
|
||||
send(c, expandcontmsg, sizeof expandcontmsg-1, 0);
|
||||
send(c, garbagemsg, sizeof garbagemsg-1, 0);
|
||||
send(c, contmsg, sizeof contmsg-1, 0);
|
||||
send(c, garbagemsg, sizeof garbagemsg-1, 0);
|
||||
send(c, okmsg, sizeof okmsg-1, 0);
|
||||
send(c, page1, sizeof page1-1, 0);
|
||||
}
|
||||
if (strstr(buffer, "GET /testG"))
|
||||
{
|
||||
send(c, page1, sizeof page1-1, 0);
|
||||
}
|
||||
|
||||
shutdown(c, 2);
|
||||
closesocket(c);
|
||||
@@ -1558,6 +1781,32 @@ static void test_basic_request(int port, const char *verb, const char *url)
|
||||
InternetCloseHandle(hi);
|
||||
}
|
||||
|
||||
static void test_last_error(int port)
|
||||
{
|
||||
HINTERNET hi, hc, hr;
|
||||
DWORD error;
|
||||
BOOL r;
|
||||
|
||||
hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||
ok(hi != NULL, "open failed\n");
|
||||
|
||||
hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
|
||||
ok(hc != NULL, "connect failed\n");
|
||||
|
||||
hr = HttpOpenRequest(hc, NULL, "/test1", NULL, NULL, NULL, 0, 0);
|
||||
ok(hr != NULL, "HttpOpenRequest failed\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
r = HttpSendRequest(hr, NULL, 0, NULL, 0);
|
||||
error = GetLastError();
|
||||
ok(r, "HttpSendRequest failed\n");
|
||||
ok(error == ERROR_SUCCESS || broken(error != ERROR_SUCCESS), "expected ERROR_SUCCESS, got %u\n", error);
|
||||
|
||||
InternetCloseHandle(hr);
|
||||
InternetCloseHandle(hc);
|
||||
InternetCloseHandle(hi);
|
||||
}
|
||||
|
||||
static void test_proxy_indirect(int port)
|
||||
{
|
||||
HINTERNET hi, hc, hr;
|
||||
@@ -1578,7 +1827,12 @@ static void test_proxy_indirect(int port)
|
||||
|
||||
sz = sizeof buffer;
|
||||
r = HttpQueryInfo(hr, HTTP_QUERY_PROXY_AUTHENTICATE, buffer, &sz, NULL);
|
||||
ok(r, "HttpQueryInfo failed\n");
|
||||
ok(r || GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo failed: %d\n", GetLastError());
|
||||
if (!r)
|
||||
{
|
||||
skip("missing proxy header, not testing remaining proxy headers\n");
|
||||
goto out;
|
||||
}
|
||||
ok(!strcmp(buffer, "Basic realm=\"placebo\""), "proxy auth info wrong\n");
|
||||
|
||||
sz = sizeof buffer;
|
||||
@@ -1611,6 +1865,7 @@ static void test_proxy_indirect(int port)
|
||||
ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo should fail\n");
|
||||
ok(r == FALSE, "HttpQueryInfo failed\n");
|
||||
|
||||
out:
|
||||
InternetCloseHandle(hr);
|
||||
InternetCloseHandle(hc);
|
||||
InternetCloseHandle(hi);
|
||||
@@ -1829,7 +2084,6 @@ static void test_http1_1(int port)
|
||||
ok(req != NULL, "HttpOpenRequest failed\n");
|
||||
|
||||
ret = HttpSendRequest(req, NULL, 0, NULL, 0);
|
||||
todo_wine
|
||||
ok(ret, "HttpSendRequest failed\n");
|
||||
}
|
||||
|
||||
@@ -1995,6 +2249,69 @@ static void test_invalid_response_headers(int port)
|
||||
InternetCloseHandle(session);
|
||||
}
|
||||
|
||||
static void test_response_without_headers(int port)
|
||||
{
|
||||
HINTERNET hi, hc, hr;
|
||||
DWORD r, count, size, status;
|
||||
char buffer[1024];
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||
ok(hi != NULL, "open failed %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
|
||||
ok(hc != NULL, "connect failed %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hr = HttpOpenRequest(hc, NULL, "/testG", NULL, NULL, NULL, 0, 0);
|
||||
ok(hr != NULL, "HttpOpenRequest failed %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
r = HttpSendRequest(hr, NULL, 0, NULL, 0);
|
||||
ok(r, "HttpSendRequest failed %u\n", GetLastError());
|
||||
|
||||
count = 0;
|
||||
memset(buffer, 0, sizeof buffer);
|
||||
SetLastError(0xdeadbeef);
|
||||
r = InternetReadFile(hr, buffer, sizeof buffer, &count);
|
||||
ok(r, "InternetReadFile failed %u\n", GetLastError());
|
||||
todo_wine ok(count == sizeof page1 - 1, "count was wrong\n");
|
||||
todo_wine ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
|
||||
|
||||
status = 0;
|
||||
size = sizeof(status);
|
||||
SetLastError(0xdeadbeef);
|
||||
r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
|
||||
todo_wine ok(r, "HttpQueryInfo failed %u\n", GetLastError());
|
||||
todo_wine ok(status == 200, "expected status 200 got %u\n", status);
|
||||
|
||||
buffer[0] = 0;
|
||||
size = sizeof(buffer);
|
||||
SetLastError(0xdeadbeef);
|
||||
r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_TEXT, buffer, &size, NULL );
|
||||
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
|
||||
ok(!strcmp(buffer, "OK"), "expected OK got: \"%s\"\n", buffer);
|
||||
|
||||
buffer[0] = 0;
|
||||
size = sizeof(buffer);
|
||||
SetLastError(0xdeadbeef);
|
||||
r = HttpQueryInfo(hr, HTTP_QUERY_VERSION, buffer, &size, NULL);
|
||||
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
|
||||
ok(!strcmp(buffer, "HTTP/1.0"), "expected HTTP/1.0 got: \"%s\"\n", buffer);
|
||||
|
||||
buffer[0] = 0;
|
||||
size = sizeof(buffer);
|
||||
SetLastError(0xdeadbeef);
|
||||
r = HttpQueryInfo(hr, HTTP_QUERY_RAW_HEADERS, buffer, &size, NULL);
|
||||
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
|
||||
ok(!strcmp(buffer, "HTTP/1.0 200 OK"), "raw headers wrong: \"%s\"\n", buffer);
|
||||
|
||||
InternetCloseHandle(hr);
|
||||
InternetCloseHandle(hc);
|
||||
InternetCloseHandle(hi);
|
||||
}
|
||||
|
||||
static void test_HttpQueryInfo(int port)
|
||||
{
|
||||
HINTERNET hi, hc, hr;
|
||||
@@ -2124,13 +2441,16 @@ static void test_http_connection(void)
|
||||
test_basic_request(si.port, "RPC_IN_DATA", "/test5");
|
||||
test_basic_request(si.port, "RPC_OUT_DATA", "/test5");
|
||||
test_basic_request(si.port, "GET", "/test6");
|
||||
test_basic_request(si.port, "GET", "/testF");
|
||||
test_connection_header(si.port);
|
||||
test_http1_1(si.port);
|
||||
test_cookie_header(si.port);
|
||||
test_basic_authentication(si.port);
|
||||
test_invalid_response_headers(si.port);
|
||||
test_response_without_headers(si.port);
|
||||
test_HttpQueryInfo(si.port);
|
||||
test_HttpSendRequestW(si.port);
|
||||
test_last_error(si.port);
|
||||
|
||||
/* send the basic request again to shutdown the server thread */
|
||||
test_basic_request(si.port, "GET", "/quit");
|
||||
@@ -2321,6 +2641,7 @@ struct notification
|
||||
unsigned int status; /* status received */
|
||||
int async; /* delivered from another thread? */
|
||||
int todo;
|
||||
int optional;
|
||||
};
|
||||
|
||||
struct info
|
||||
@@ -2356,6 +2677,13 @@ static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DW
|
||||
return;
|
||||
}
|
||||
|
||||
while (info->test[i].status != status && info->test[i].optional &&
|
||||
i < info->count - 1 &&
|
||||
info->test[i].function == info->test[i + 1].function)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
status_ok = (info->test[i].status == status);
|
||||
function_ok = (info->test[i].function == info->function);
|
||||
|
||||
@@ -2375,7 +2703,7 @@ static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DW
|
||||
todo_wine ok( function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function );
|
||||
}
|
||||
if (i == info->count - 1 || info->test[i].function != info->test[i + 1].function) SetEvent( info->wait );
|
||||
info->index++;
|
||||
info->index = i+1;
|
||||
|
||||
LeaveCriticalSection( ¬ification_cs );
|
||||
}
|
||||
@@ -2390,6 +2718,7 @@ static const struct notification async_send_request_ex_test[] =
|
||||
{
|
||||
{ internet_connect, INTERNET_STATUS_HANDLE_CREATED, 0 },
|
||||
{ http_open_request, INTERNET_STATUS_HANDLE_CREATED, 0 },
|
||||
{ http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 },
|
||||
{ http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, 1 },
|
||||
{ http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, 1 },
|
||||
{ http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, 1 },
|
||||
@@ -2493,6 +2822,7 @@ static void test_async_HttpSendRequestEx(void)
|
||||
InternetCloseHandle( ses );
|
||||
|
||||
WaitForSingleObject( info.wait, 10000 );
|
||||
Sleep(100);
|
||||
CloseHandle( info.wait );
|
||||
}
|
||||
|
||||
@@ -2548,8 +2878,11 @@ START_TEST(http)
|
||||
else
|
||||
{
|
||||
init_status_tests();
|
||||
InternetReadFile_test(INTERNET_FLAG_ASYNC);
|
||||
InternetReadFile_test(0);
|
||||
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[0]);
|
||||
InternetReadFile_test(0, &test_data[0]);
|
||||
first_connection_to_test_url = TRUE;
|
||||
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[1]);
|
||||
InternetReadFile_test(0, &test_data[1]);
|
||||
InternetReadFileExA_test(INTERNET_FLAG_ASYNC);
|
||||
test_open_url_async();
|
||||
test_async_HttpSendRequestEx();
|
||||
@@ -2557,9 +2890,10 @@ START_TEST(http)
|
||||
InternetOpenRequest_test();
|
||||
test_http_cache();
|
||||
InternetOpenUrlA_test();
|
||||
HttpSendRequestEx_test();
|
||||
HttpHeaders_test();
|
||||
test_http_connection();
|
||||
test_user_agent_header();
|
||||
test_bogus_accept_types_array();
|
||||
InternetReadFile_chunked_test();
|
||||
HttpSendRequestEx_test();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "winbase.h"
|
||||
#include "wininet.h"
|
||||
#include "winerror.h"
|
||||
#include "winreg.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
@@ -36,6 +37,18 @@ static BOOL (WINAPI *pInternetTimeFromSystemTimeW)(CONST SYSTEMTIME *,DWORD ,LPW
|
||||
static BOOL (WINAPI *pInternetTimeToSystemTimeA)(LPCSTR ,SYSTEMTIME *,DWORD);
|
||||
static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
|
||||
static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
|
||||
static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
|
||||
static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
|
||||
|
||||
/* Win9x and WinMe don't have lstrcmpW */
|
||||
static int strcmp_ww(const WCHAR *str1, const WCHAR *str2)
|
||||
{
|
||||
DWORD len1 = lstrlenW(str1);
|
||||
DWORD len2 = lstrlenW(str2);
|
||||
|
||||
if (len1 != len2) return 1;
|
||||
return memcmp(str1, str2, len1 * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
/* ############################### */
|
||||
|
||||
@@ -182,7 +195,7 @@ static void test_InternetQueryOptionA(void)
|
||||
if (retval)
|
||||
{
|
||||
ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
|
||||
todo_wine ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
|
||||
ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
|
||||
}
|
||||
ok(err == 0xdeadbeef, "Got wrong error code %d\n",err);
|
||||
HeapFree(GetProcessHeap(),0,buffer);
|
||||
@@ -229,7 +242,7 @@ static void test_InternetQueryOptionA(void)
|
||||
len=0;
|
||||
retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
|
||||
err=GetLastError();
|
||||
todo_wine ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
|
||||
ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
|
||||
ok(retval == 0,"Got wrong return value %d\n",retval);
|
||||
ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
|
||||
|
||||
@@ -463,7 +476,7 @@ static void test_null(void)
|
||||
ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
|
||||
|
||||
/* before XP SP2, buffer is "server; server" */
|
||||
ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
|
||||
ok( !strcmp_ww(szExpect, buffer) || !strcmp_ww(szServer, buffer), "cookie data wrong\n");
|
||||
|
||||
sz = sizeof(buffer);
|
||||
r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
|
||||
@@ -742,8 +755,9 @@ static void test_IsDomainLegalCookieDomainW(void)
|
||||
error = GetLastError();
|
||||
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
|
||||
ok(error == ERROR_SXS_KEY_NOT_FOUND ||
|
||||
error == ERROR_SUCCESS || /* IE8 on W2K3 */
|
||||
error == 0xdeadbeef, /* up to IE7 */
|
||||
"got %u expected ERROR_SXS_KEY_NOT_FOUND or 0xdeadbeef\n", error);
|
||||
"unexpected error: %u\n", error);
|
||||
|
||||
ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
|
||||
ok(ret, "IsDomainLegalCookieDomainW failed\n");
|
||||
@@ -754,9 +768,9 @@ static void test_IsDomainLegalCookieDomainW(void)
|
||||
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
|
||||
ok(error == ERROR_SXS_KEY_NOT_FOUND || /* IE8 on XP */
|
||||
error == ERROR_FILE_NOT_FOUND || /* IE8 on Vista */
|
||||
error == ERROR_SUCCESS || /* IE8 on W2K3 */
|
||||
error == 0xdeadbeef, /* up to IE7 */
|
||||
"got %u expected ERROR_SXS_KEY_NOT_FOUND, ERROR_FILE_NOT_FOUND or "
|
||||
"0xdeadbeef\n", error);
|
||||
"unexpected error: %u\n", error);
|
||||
|
||||
ret = pIsDomainLegalCookieDomainW(uk, co_uk);
|
||||
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
|
||||
@@ -794,6 +808,273 @@ static void test_IsDomainLegalCookieDomainW(void)
|
||||
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
|
||||
}
|
||||
|
||||
static void test_PrivacyGetSetZonePreferenceW(void)
|
||||
{
|
||||
DWORD ret, zone, type, template, old_template;
|
||||
|
||||
zone = 3;
|
||||
type = 0;
|
||||
ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
|
||||
ok(ret == 0, "expected ret == 0, got %u\n", ret);
|
||||
|
||||
old_template = 0;
|
||||
ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
|
||||
ok(ret == 0, "expected ret == 0, got %u\n", ret);
|
||||
|
||||
template = 5;
|
||||
ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
|
||||
ok(ret == 0, "expected ret == 0, got %u\n", ret);
|
||||
|
||||
template = 0;
|
||||
ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
|
||||
ok(ret == 0, "expected ret == 0, got %u\n", ret);
|
||||
ok(template == 5, "expected template == 5, got %u\n", template);
|
||||
|
||||
template = 5;
|
||||
ret = pPrivacySetZonePreferenceW(zone, type, old_template, NULL);
|
||||
ok(ret == 0, "expected ret == 0, got %u\n", ret);
|
||||
}
|
||||
|
||||
static void test_Option_Policy(void)
|
||||
{
|
||||
HINTERNET hinet;
|
||||
BOOL ret;
|
||||
|
||||
hinet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||
ok(hinet != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = InternetSetOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
|
||||
ok(ret == FALSE, "InternetSetOption should've failed\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
|
||||
"given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = InternetQueryOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
|
||||
ok(ret == FALSE, "InternetQueryOption should've failed\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
|
||||
"given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
|
||||
|
||||
ret = InternetCloseHandle(hinet);
|
||||
ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
|
||||
}
|
||||
|
||||
#define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
|
||||
static void r_verifyProxyEnable(LONG l, DWORD exp)
|
||||
{
|
||||
HKEY hkey;
|
||||
DWORD type, val, size = sizeof(DWORD);
|
||||
LONG ret;
|
||||
static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
|
||||
static const CHAR szProxyEnable[] = "ProxyEnable";
|
||||
|
||||
ret = RegOpenKeyA(HKEY_CURRENT_USER, szInternetSettings, &hkey);
|
||||
ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
|
||||
|
||||
ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
|
||||
ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
|
||||
ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
|
||||
ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
|
||||
|
||||
ret = RegCloseKey(hkey);
|
||||
ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
|
||||
}
|
||||
|
||||
static void test_Option_PerConnectionOption(void)
|
||||
{
|
||||
BOOL ret;
|
||||
DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
|
||||
INTERNET_PER_CONN_OPTION_LISTW list = {size};
|
||||
INTERNET_PER_CONN_OPTIONW *orig_settings;
|
||||
static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
|
||||
|
||||
/* get the global IE proxy server info, to restore later */
|
||||
list.dwOptionCount = 2;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
||||
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
|
||||
ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, &size);
|
||||
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
|
||||
orig_settings = list.pOptions;
|
||||
|
||||
/* set the global IE proxy server */
|
||||
list.dwOptionCount = 2;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
||||
list.pOptions[0].Value.pszValue = proxy_srvW;
|
||||
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
|
||||
|
||||
ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, size);
|
||||
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
|
||||
/* get & verify the global IE proxy server */
|
||||
list.dwOptionCount = 2;
|
||||
list.dwOptionError = 0;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
||||
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
|
||||
ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, &size);
|
||||
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
|
||||
ok(!strcmp_ww(list.pOptions[0].Value.pszValue, proxy_srvW),
|
||||
"Retrieved proxy server should've been %s, was: %s\n",
|
||||
wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
|
||||
ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
|
||||
"Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
|
||||
list.pOptions[1].Value.dwValue);
|
||||
verifyProxyEnable(1);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
|
||||
/* disable the proxy server */
|
||||
list.dwOptionCount = 1;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
|
||||
|
||||
ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, size);
|
||||
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
|
||||
/* verify that the proxy is disabled */
|
||||
list.dwOptionCount = 1;
|
||||
list.dwOptionError = 0;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
|
||||
ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, &size);
|
||||
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
|
||||
ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
|
||||
"Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
|
||||
list.pOptions[0].Value.dwValue);
|
||||
verifyProxyEnable(0);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
|
||||
/* set the proxy flags to 'invalid' value */
|
||||
list.dwOptionCount = 1;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
|
||||
|
||||
ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, size);
|
||||
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
|
||||
/* verify that the proxy is enabled */
|
||||
list.dwOptionCount = 1;
|
||||
list.dwOptionError = 0;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
|
||||
ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, &size);
|
||||
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
|
||||
todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
|
||||
"Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
|
||||
list.pOptions[0].Value.dwValue);
|
||||
verifyProxyEnable(1);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
|
||||
/* restore original settings */
|
||||
list.dwOptionCount = 2;
|
||||
list.pOptions = orig_settings;
|
||||
|
||||
ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, size);
|
||||
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
}
|
||||
|
||||
static void test_Option_PerConnectionOptionA(void)
|
||||
{
|
||||
BOOL ret;
|
||||
DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
|
||||
INTERNET_PER_CONN_OPTION_LISTA list = {size};
|
||||
INTERNET_PER_CONN_OPTIONA *orig_settings;
|
||||
char proxy_srv[] = "proxy.example";
|
||||
|
||||
/* get the global IE proxy server info, to restore later */
|
||||
list.dwOptionCount = 2;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
||||
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
|
||||
ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, &size);
|
||||
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
|
||||
orig_settings = list.pOptions;
|
||||
|
||||
/* set the global IE proxy server */
|
||||
list.dwOptionCount = 2;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
||||
list.pOptions[0].Value.pszValue = proxy_srv;
|
||||
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
|
||||
|
||||
ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, size);
|
||||
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
|
||||
/* get & verify the global IE proxy server */
|
||||
list.dwOptionCount = 2;
|
||||
list.dwOptionError = 0;
|
||||
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
|
||||
|
||||
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
||||
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||
|
||||
ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, &size);
|
||||
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
|
||||
ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
|
||||
"Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
|
||||
proxy_srv, list.pOptions[0].Value.pszValue);
|
||||
ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
|
||||
"Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
|
||||
list.pOptions[1].Value.dwValue);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
|
||||
/* restore original settings */
|
||||
list.dwOptionCount = 2;
|
||||
list.pOptions = orig_settings;
|
||||
|
||||
ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
|
||||
&list, size);
|
||||
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, list.pOptions);
|
||||
}
|
||||
|
||||
/* ############################### */
|
||||
|
||||
START_TEST(internet)
|
||||
@@ -807,6 +1088,8 @@ START_TEST(internet)
|
||||
pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
|
||||
pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
|
||||
pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
|
||||
pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
|
||||
pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
|
||||
|
||||
test_InternetCanonicalizeUrlA();
|
||||
test_InternetQueryOptionA();
|
||||
@@ -814,6 +1097,9 @@ START_TEST(internet)
|
||||
test_complicated_cookie();
|
||||
test_version();
|
||||
test_null();
|
||||
test_Option_Policy();
|
||||
test_Option_PerConnectionOption();
|
||||
test_Option_PerConnectionOptionA();
|
||||
|
||||
if (!pInternetTimeFromSystemTimeA)
|
||||
win_skip("skipping the InternetTime tests\n");
|
||||
@@ -832,4 +1118,9 @@ START_TEST(internet)
|
||||
win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
|
||||
else
|
||||
test_IsDomainLegalCookieDomainW();
|
||||
|
||||
if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
|
||||
test_PrivacyGetSetZonePreferenceW();
|
||||
else
|
||||
win_skip("Privacy[SG]etZonePreferenceW are not available\n");
|
||||
}
|
||||
|
||||
@@ -23,21 +23,16 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
#include "wininet.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#define TEST_URL "http://www.winehq.org/site/about"
|
||||
#define TEST_URL_HOST "www.winehq.org"
|
||||
#define TEST_URL_PATH "/site/about"
|
||||
#define TEST_URL2 "http://www.myserver.com/myscript.php?arg=1"
|
||||
#define TEST_URL2_SERVER "www.myserver.com"
|
||||
#define TEST_URL2_PATH "/myscript.php"
|
||||
#define TEST_URL2_PATHEXTRA "/myscript.php?arg=1"
|
||||
#define TEST_URL2_EXTRA "?arg=1"
|
||||
#define TEST_URL "http://www.winehq.org/site/about#hi"
|
||||
#define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
|
||||
|
||||
#define CREATE_URL1 "http://username:[email protected]/site/about"
|
||||
@@ -94,6 +89,190 @@ static void zero_compsA(
|
||||
SetLastError(0xfaceabad);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *url;
|
||||
int scheme_off;
|
||||
int scheme_len;
|
||||
INTERNET_SCHEME scheme;
|
||||
int host_off;
|
||||
int host_len;
|
||||
int host_skip_broken;
|
||||
INTERNET_PORT port;
|
||||
int user_off;
|
||||
int user_len;
|
||||
int pass_off;
|
||||
int pass_len;
|
||||
int path_off;
|
||||
int path_len;
|
||||
int extra_off;
|
||||
int extra_len;
|
||||
} crack_url_test_t;
|
||||
|
||||
static const crack_url_test_t crack_url_tests[] = {
|
||||
{"http://www.winehq.org/site/about#hi",
|
||||
0, 4, INTERNET_SCHEME_HTTP, 7, 14, -1, 80, -1, 0, -1, 0, 21, 11, 32, 3},
|
||||
{"http://www.myserver.com/myscript.php?arg=1",
|
||||
0, 4, INTERNET_SCHEME_HTTP, 7, 16, -1, 80, -1, 0, -1, 0, 23, 13, 36, 6},
|
||||
{"http://www.winehq.org?test=123",
|
||||
0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 0, 21, 9},
|
||||
{"file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
|
||||
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0},
|
||||
{"fide:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
|
||||
0, 4, INTERNET_SCHEME_UNKNOWN, 7, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0},
|
||||
{"file://C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
|
||||
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 54, -1, 0},
|
||||
};
|
||||
|
||||
static void test_crack_url(const crack_url_test_t *test)
|
||||
{
|
||||
WCHAR buf[INTERNET_MAX_URL_LENGTH];
|
||||
URL_COMPONENTSW urlw;
|
||||
URL_COMPONENTSA url;
|
||||
BOOL b;
|
||||
|
||||
zero_compsA(&url, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
b = InternetCrackUrlA(test->url, strlen(test->url), 0, &url);
|
||||
ok(b, "InternetCrackUrl failed with error %d\n", GetLastError());
|
||||
|
||||
if(test->scheme_off == -1)
|
||||
ok(!url.lpszScheme, "[%s] url.lpszScheme = %p, expected NULL\n", test->url, url.lpszScheme);
|
||||
else
|
||||
ok(url.lpszScheme == test->url+test->scheme_off, "[%s] url.lpszScheme = %p, expected %p\n",
|
||||
test->url, url.lpszScheme, test->url+test->scheme_off);
|
||||
ok(url.dwSchemeLength == test->scheme_len, "[%s] url.lpszSchemeLength = %d, expected %d\n",
|
||||
test->url, url.dwSchemeLength, test->scheme_len);
|
||||
|
||||
ok(url.nScheme == test->scheme, "[%s] url.nScheme = %d, expected %d\n", test->url, url.nScheme, test->scheme);
|
||||
|
||||
if(test->host_off == -1)
|
||||
ok(!url.lpszHostName, "[%s] url.lpszHostName = %p, expected NULL\n", test->url, url.lpszHostName);
|
||||
else
|
||||
ok(url.lpszHostName == test->url+test->host_off, "[%s] url.lpszHostName = %p, expected %p\n",
|
||||
test->url, url.lpszHostName, test->url+test->host_off);
|
||||
if(test->host_skip_broken != -1 && url.dwHostNameLength == test->host_skip_broken) {
|
||||
win_skip("skipping broken dwHostNameLength result\n");
|
||||
return;
|
||||
}
|
||||
ok(url.dwHostNameLength == test->host_len, "[%s] url.lpszHostNameLength = %d, expected %d\n",
|
||||
test->url, url.dwHostNameLength, test->host_len);
|
||||
|
||||
ok(url.nPort == test->port, "[%s] nPort = %d, expected %d\n", test->url, url.nPort, test->port);
|
||||
|
||||
if(test->user_off == -1)
|
||||
ok(!url.lpszUserName, "[%s] url.lpszUserName = %p\n", test->url, url.lpszUserName);
|
||||
else
|
||||
ok(url.lpszUserName == test->url+test->user_off, "[%s] url.lpszUserName = %p, expected %p\n",
|
||||
test->url, url.lpszUserName, test->url+test->user_off);
|
||||
ok(url.dwUserNameLength == test->user_len, "[%s] url.lpszUserNameLength = %d, expected %d\n",
|
||||
test->url, url.dwUserNameLength, test->user_len);
|
||||
|
||||
if(test->pass_off == -1)
|
||||
ok(!url.lpszPassword, "[%s] url.lpszPassword = %p\n", test->url, url.lpszPassword);
|
||||
else
|
||||
ok(url.lpszPassword == test->url+test->pass_off, "[%s] url.lpszPassword = %p, expected %p\n",
|
||||
test->url, url.lpszPassword, test->url+test->pass_off);
|
||||
ok(url.dwPasswordLength == test->pass_len, "[%s] url.lpszPasswordLength = %d, expected %d\n",
|
||||
test->url, url.dwPasswordLength, test->pass_len);
|
||||
|
||||
if(test->path_off == -1)
|
||||
ok(!url.lpszUrlPath, "[%s] url.lpszPath = %p, expected NULL\n", test->url, url.lpszUrlPath);
|
||||
else
|
||||
ok(url.lpszUrlPath == test->url+test->path_off, "[%s] url.lpszPath = %p, expected %p\n",
|
||||
test->url, url.lpszUrlPath, test->url+test->path_off);
|
||||
ok(url.dwUrlPathLength == test->path_len, "[%s] url.lpszUrlPathLength = %d, expected %d\n",
|
||||
test->url, url.dwUrlPathLength, test->path_len);
|
||||
|
||||
if(test->extra_off == -1)
|
||||
ok(!url.lpszExtraInfo, "[%s] url.lpszExtraInfo = %p, expected NULL\n", test->url, url.lpszExtraInfo);
|
||||
else
|
||||
ok(url.lpszExtraInfo == test->url+test->extra_off, "[%s] url.lpszExtraInfo = %p, expected %p\n",
|
||||
test->url, url.lpszExtraInfo, test->url+test->extra_off);
|
||||
ok(url.dwExtraInfoLength == test->extra_len, "[%s] url.lpszExtraInfoLength = %d, expected %d\n",
|
||||
test->url, url.dwExtraInfoLength, test->extra_len);
|
||||
|
||||
memset(&urlw, 0, sizeof(URL_COMPONENTSW));
|
||||
urlw.dwStructSize = sizeof(URL_COMPONENTSW);
|
||||
urlw.dwSchemeLength = 1;
|
||||
urlw.dwHostNameLength = 1;
|
||||
urlw.dwUserNameLength = 1;
|
||||
urlw.dwPasswordLength = 1;
|
||||
urlw.dwUrlPathLength = 1;
|
||||
urlw.dwExtraInfoLength = 1;
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, test->url, -1, buf, sizeof(buf));
|
||||
b = InternetCrackUrlW(buf, lstrlenW(buf), 0, &urlw);
|
||||
if(!b && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
|
||||
win_skip("InternetCrackUrlW is not implemented\n");
|
||||
return;
|
||||
}
|
||||
ok(b, "InternetCrackUrl failed with error %d\n", GetLastError());
|
||||
|
||||
if(test->scheme_off == -1)
|
||||
ok(!urlw.lpszScheme, "[%s] urlw.lpszScheme = %p, expected NULL\n", test->url, urlw.lpszScheme);
|
||||
else
|
||||
ok(urlw.lpszScheme == buf+test->scheme_off, "[%s] urlw.lpszScheme = %p, expected %p\n",
|
||||
test->url, urlw.lpszScheme, buf+test->scheme_off);
|
||||
ok(urlw.dwSchemeLength == test->scheme_len, "[%s] urlw.lpszSchemeLength = %d, expected %d\n",
|
||||
test->url, urlw.dwSchemeLength, test->scheme_len);
|
||||
|
||||
ok(urlw.nScheme == test->scheme, "[%s] urlw.nScheme = %d, expected %d\n", test->url, urlw.nScheme, test->scheme);
|
||||
|
||||
if(test->host_off == -1) {
|
||||
ok(!urlw.lpszHostName, "[%s] urlw.lpszHostName = %p, expected NULL\n", test->url, urlw.lpszHostName);
|
||||
ok(urlw.dwHostNameLength == 0 || broken(urlw.dwHostNameLength == 1), "[%s] urlw.lpszHostNameLength = %d, expected %d\n",
|
||||
test->url, urlw.dwHostNameLength, test->host_len);
|
||||
}else {
|
||||
ok(urlw.lpszHostName == buf+test->host_off, "[%s] urlw.lpszHostName = %p, expected %p\n",
|
||||
test->url, urlw.lpszHostName, test->url+test->host_off);
|
||||
ok(urlw.dwHostNameLength == test->host_len, "[%s] urlw.lpszHostNameLength = %d, expected %d\n",
|
||||
test->url, urlw.dwHostNameLength, test->host_len);
|
||||
}
|
||||
|
||||
ok(urlw.nPort == test->port, "[%s] nPort = %d, expected %d\n", test->url, urlw.nPort, test->port);
|
||||
|
||||
if(test->user_off == -1) {
|
||||
ok(!urlw.lpszUserName, "[%s] urlw.lpszUserName = %p\n", test->url, urlw.lpszUserName);
|
||||
ok(urlw.dwUserNameLength == 0 || broken(urlw.dwUserNameLength == 1), "[%s] urlw.lpszUserNameLength = %d, expected %d\n",
|
||||
test->url, urlw.dwUserNameLength, test->user_len);
|
||||
}else {
|
||||
ok(urlw.lpszUserName == buf+test->user_off, "[%s] urlw.lpszUserName = %p, expected %p\n",
|
||||
test->url, urlw.lpszUserName, buf+test->user_off);
|
||||
ok(urlw.dwUserNameLength == test->user_len, "[%s] urlw.lpszUserNameLength = %d, expected %d\n",
|
||||
test->url, urlw.dwUserNameLength, test->user_len);
|
||||
}
|
||||
|
||||
if(test->pass_off == -1) {
|
||||
ok(!urlw.lpszPassword, "[%s] urlw.lpszPassword = %p\n", test->url, urlw.lpszPassword);
|
||||
ok(urlw.dwPasswordLength == 0 || broken(urlw.dwPasswordLength), "[%s] urlw.lpszPasswordLength = %d, expected %d\n",
|
||||
test->url, urlw.dwPasswordLength, test->pass_len);
|
||||
}else {
|
||||
ok(urlw.lpszPassword == buf+test->pass_off, "[%s] urlw.lpszPassword = %p, expected %p\n",
|
||||
test->url, urlw.lpszPassword, buf+test->pass_off);
|
||||
ok(urlw.dwPasswordLength == test->pass_len, "[%s] urlw.lpszPasswordLength = %d, expected %d\n",
|
||||
test->url, urlw.dwPasswordLength, test->pass_len);
|
||||
}
|
||||
|
||||
if(test->path_off == -1)
|
||||
ok(!urlw.lpszUrlPath, "[%s] urlw.lpszPath = %p, expected NULL\n", test->url, urlw.lpszUrlPath);
|
||||
else
|
||||
ok(urlw.lpszUrlPath == buf+test->path_off, "[%s] urlw.lpszPath = %p, expected %p\n",
|
||||
test->url, urlw.lpszUrlPath, buf+test->path_off);
|
||||
ok(urlw.dwUrlPathLength == test->path_len, "[%s] urlw.lpszUrlPathLength = %d, expected %d\n",
|
||||
test->url, urlw.dwUrlPathLength, test->path_len);
|
||||
|
||||
if(test->extra_off == -1) {
|
||||
ok(!urlw.lpszExtraInfo, "[%s] url.lpszExtraInfo = %p, expected NULL\n", test->url, urlw.lpszExtraInfo);
|
||||
ok(urlw.dwExtraInfoLength == 0 || broken(urlw.dwExtraInfoLength == 1), "[%s] urlw.lpszExtraInfoLength = %d, expected %d\n",
|
||||
test->url, urlw.dwExtraInfoLength, test->extra_len);
|
||||
}else {
|
||||
ok(urlw.lpszExtraInfo == buf+test->extra_off, "[%s] urlw.lpszExtraInfo = %p, expected %p\n",
|
||||
test->url, urlw.lpszExtraInfo, buf+test->extra_off);
|
||||
ok(urlw.dwExtraInfoLength == test->extra_len, "[%s] urlw.lpszExtraInfoLength = %d, expected %d\n",
|
||||
test->url, urlw.dwExtraInfoLength, test->extra_len);
|
||||
}
|
||||
}
|
||||
|
||||
static void InternetCrackUrl_test(void)
|
||||
{
|
||||
URL_COMPONENTSA urlSrc, urlComponents;
|
||||
@@ -111,51 +290,6 @@ static void InternetCrackUrl_test(void)
|
||||
urlSrc.lpszUrlPath = path;
|
||||
urlSrc.lpszExtraInfo = extra;
|
||||
|
||||
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
|
||||
ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
|
||||
ok( ret, "InternetCrackUrl failed, error %d\n",GetLastError());
|
||||
ok((strcmp(TEST_URL_PATH,path) == 0),"path cracked wrong\n");
|
||||
|
||||
/* Bug 1805: Confirm the returned lengths are correct: */
|
||||
/* 1. When extra info split out explicitly */
|
||||
zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 1);
|
||||
ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed, error %d\n", GetLastError());
|
||||
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATH),".dwUrlPathLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_PATH), urlComponents.dwUrlPathLength);
|
||||
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATH,strlen(TEST_URL2_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH, urlComponents.lpszUrlPath);
|
||||
ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
|
||||
ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
|
||||
ok(urlComponents.dwExtraInfoLength == strlen(TEST_URL2_EXTRA),".dwExtraInfoLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_EXTRA), urlComponents.dwExtraInfoLength);
|
||||
ok(!strncmp(urlComponents.lpszExtraInfo,TEST_URL2_EXTRA,strlen(TEST_URL2_EXTRA)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA, urlComponents.lpszHostName);
|
||||
|
||||
/* 2. When extra info is not split out explicitly and is in url path */
|
||||
zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 0);
|
||||
ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
|
||||
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATHEXTRA),".dwUrlPathLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_PATHEXTRA), urlComponents.dwUrlPathLength);
|
||||
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath);
|
||||
ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
|
||||
ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
|
||||
ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort);
|
||||
ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme);
|
||||
|
||||
zero_compsA(&urlComponents, 1, 1, 1, 1, 1, 1);
|
||||
ok(InternetCrackUrlA(TEST_URL, strlen(TEST_URL), 0, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
|
||||
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL_PATH),".dwUrlPathLength should be %d, but is %d\n", lstrlenA(TEST_URL_PATH), urlComponents.dwUrlPathLength);
|
||||
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL_PATH,strlen(TEST_URL_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL_PATH, urlComponents.lpszUrlPath);
|
||||
ok(urlComponents.dwHostNameLength == strlen(TEST_URL_HOST),".dwHostNameLength should be %d, but is %d\n", lstrlenA(TEST_URL_HOST), urlComponents.dwHostNameLength);
|
||||
ok(!strncmp(urlComponents.lpszHostName,TEST_URL_HOST,strlen(TEST_URL_HOST)),"lpszHostName should be %s but is %s\n", TEST_URL_HOST, urlComponents.lpszHostName);
|
||||
ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort);
|
||||
ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme);
|
||||
ok(!urlComponents.lpszUserName, ".lpszUserName should have been set to NULL\n");
|
||||
ok(!urlComponents.lpszPassword, ".lpszPassword should have been set to NULL\n");
|
||||
ok(!urlComponents.lpszExtraInfo, ".lpszExtraInfo should have been set to NULL\n");
|
||||
ok(!urlComponents.dwUserNameLength,".dwUserNameLength should be 0, but is %d\n", urlComponents.dwUserNameLength);
|
||||
ok(!urlComponents.dwPasswordLength,".dwPasswordLength should be 0, but is %d\n", urlComponents.dwPasswordLength);
|
||||
ok(!urlComponents.dwExtraInfoLength,".dwExtraInfoLength should be 0, but is %d\n", urlComponents.dwExtraInfoLength);
|
||||
|
||||
/*3. Check for %20 */
|
||||
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
|
||||
ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
|
||||
|
||||
/* Tests for lpsz* members pointing to real strings while
|
||||
* some corresponding length members are set to zero.
|
||||
* As of IE7 (wininet 7.0*?) all members are checked. So we
|
||||
@@ -810,6 +944,11 @@ static void InternetCreateUrlA_test(void)
|
||||
|
||||
START_TEST(url)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i < sizeof(crack_url_tests)/sizeof(*crack_url_tests); i++)
|
||||
test_crack_url(crack_url_tests+i);
|
||||
|
||||
InternetCrackUrl_test();
|
||||
InternetCrackUrlW_test();
|
||||
InternetCreateUrlA_test();
|
||||
|
||||
@@ -25,15 +25,18 @@
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wininet.h"
|
||||
#include "winineti.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#define TEST_URL "http://urlcachetest.winehq.org/index.html"
|
||||
#define TEST_URL1 "Visited: user@http://urlcachetest.winehq.org/index.html"
|
||||
|
||||
static BOOL (WINAPI *pDeleteUrlCacheEntryA)(LPCSTR);
|
||||
static BOOL (WINAPI *pUnlockUrlCacheEntryFileA)(LPCSTR,DWORD);
|
||||
|
||||
static char filenameA[MAX_PATH + 1];
|
||||
static char filenameA1[MAX_PATH + 1];
|
||||
|
||||
static void check_cache_entry_infoA(const char *returnedfrom, LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo)
|
||||
{
|
||||
@@ -53,6 +56,7 @@ static void test_find_url_cache_entriesA(void)
|
||||
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo;
|
||||
|
||||
cbCacheEntryInfo = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
hEnumHandle = FindFirstUrlCacheEntry(NULL, NULL, &cbCacheEntryInfo);
|
||||
ok(!hEnumHandle, "FindFirstUrlCacheEntry should have failed\n");
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "FindFirstUrlCacheEntry should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
|
||||
@@ -67,6 +71,7 @@ static void test_find_url_cache_entriesA(void)
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
SetLastError(0xdeadbeef);
|
||||
cbCacheEntryInfo = cbCacheEntryInfoSaved;
|
||||
ret = FindNextUrlCacheEntry(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo);
|
||||
if (!ret)
|
||||
@@ -94,19 +99,37 @@ static void test_GetUrlCacheEntryInfoExA(void)
|
||||
DWORD cbCacheEntryInfo;
|
||||
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetUrlCacheEntryInfoEx(NULL, NULL, NULL, NULL, NULL, NULL, 0);
|
||||
ok(!ret, "GetUrlCacheEntryInfoEx with NULL URL and NULL args should have failed\n");
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetUrlCacheEntryInfoEx with NULL URL and NULL args should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"GetUrlCacheEntryInfoEx with NULL URL and NULL args should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
|
||||
|
||||
cbCacheEntryInfo = sizeof(INTERNET_CACHE_ENTRY_INFO);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetUrlCacheEntryInfoEx("", NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
|
||||
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
|
||||
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
|
||||
"GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
|
||||
|
||||
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, NULL, NULL, NULL, NULL, 0);
|
||||
ok(ret, "GetUrlCacheEntryInfoEx with NULL args failed with error %d\n", GetLastError());
|
||||
|
||||
cbCacheEntryInfo = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
|
||||
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||
"GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
|
||||
|
||||
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0x200);
|
||||
ok(!ret, "GetUrlCacheEntryInfoEx succeeded\n");
|
||||
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
|
||||
"GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
|
||||
|
||||
ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
|
||||
ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
|
||||
|
||||
@@ -161,6 +184,11 @@ static void test_urlcacheA(void)
|
||||
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0);
|
||||
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
|
||||
|
||||
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0);
|
||||
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
|
||||
|
||||
ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
|
||||
|
||||
hFile = CreateFileA(filenameA, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA failed with error %d\n", GetLastError());
|
||||
@@ -170,13 +198,21 @@ static void test_urlcacheA(void)
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, NULL, 0, NULL, NULL);
|
||||
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
|
||||
|
||||
ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, NULL, 0, NULL, NULL);
|
||||
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
|
||||
|
||||
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
|
||||
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
|
||||
|
||||
cbCacheEntryInfo = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, &cbCacheEntryInfo, 0);
|
||||
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||
"RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
|
||||
|
||||
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
|
||||
ret = RetrieveUrlCacheEntryFile(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, 0);
|
||||
@@ -186,6 +222,13 @@ static void test_urlcacheA(void)
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
|
||||
|
||||
cbCacheEntryInfo = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = RetrieveUrlCacheEntryFile(TEST_URL1, NULL, &cbCacheEntryInfo, 0);
|
||||
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
|
||||
ok(GetLastError() == ERROR_INVALID_DATA,
|
||||
"RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_DATA instead of %d\n", GetLastError());
|
||||
|
||||
if (pUnlockUrlCacheEntryFileA)
|
||||
{
|
||||
ret = pUnlockUrlCacheEntryFileA(TEST_URL, 0);
|
||||
@@ -202,8 +245,11 @@ static void test_urlcacheA(void)
|
||||
{
|
||||
ret = pDeleteUrlCacheEntryA(TEST_URL);
|
||||
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
|
||||
ret = pDeleteUrlCacheEntryA(TEST_URL1);
|
||||
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
|
||||
}
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = DeleteFile(filenameA);
|
||||
todo_wine
|
||||
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n");
|
||||
@@ -213,12 +259,54 @@ static void test_FindCloseUrlCache(void)
|
||||
{
|
||||
BOOL r;
|
||||
DWORD err;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
r = FindCloseUrlCache(NULL);
|
||||
err = GetLastError();
|
||||
ok(0 == r, "expected 0, got %d\n", r);
|
||||
ok(ERROR_INVALID_HANDLE == err, "expected %d, got %d\n", ERROR_INVALID_HANDLE, err);
|
||||
}
|
||||
|
||||
static void test_GetDiskInfoA(void)
|
||||
{
|
||||
BOOL ret;
|
||||
DWORD error, cluster_size;
|
||||
DWORDLONG free, total;
|
||||
char path[MAX_PATH], *p;
|
||||
|
||||
GetSystemDirectoryA(path, MAX_PATH);
|
||||
if ((p = strchr(path, '\\'))) *++p = 0;
|
||||
|
||||
ret = GetDiskInfoA(path, &cluster_size, &free, &total);
|
||||
ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
|
||||
|
||||
ret = GetDiskInfoA(path, &cluster_size, &free, NULL);
|
||||
ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
|
||||
|
||||
ret = GetDiskInfoA(path, &cluster_size, NULL, NULL);
|
||||
ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
|
||||
|
||||
ret = GetDiskInfoA(path, NULL, NULL, NULL);
|
||||
ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
strcpy(p, "\\non\\existing\\path");
|
||||
ret = GetDiskInfoA(path, NULL, NULL, NULL);
|
||||
error = GetLastError();
|
||||
ok(!ret ||
|
||||
broken(ret), /* < IE7 */
|
||||
"GetDiskInfoA succeeded\n");
|
||||
ok(error == ERROR_PATH_NOT_FOUND ||
|
||||
broken(error == 0xdeadbeef), /* < IE7 */
|
||||
"got %u expected ERROR_PATH_NOT_FOUND\n", error);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetDiskInfoA(NULL, NULL, NULL, NULL);
|
||||
error = GetLastError();
|
||||
ok(!ret, "GetDiskInfoA succeeded\n");
|
||||
ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
|
||||
}
|
||||
|
||||
START_TEST(urlcache)
|
||||
{
|
||||
HMODULE hdll;
|
||||
@@ -227,4 +315,5 @@ START_TEST(urlcache)
|
||||
pUnlockUrlCacheEntryFileA = (void*)GetProcAddress(hdll, "UnlockUrlCacheEntryFileA");
|
||||
test_urlcacheA();
|
||||
test_FindCloseUrlCache();
|
||||
test_GetDiskInfoA();
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
<group>
|
||||
<module name="wininet_winetest" type="win32cui" installbase="bin" installname="wininet_winetest.exe" allowwarnings="true">
|
||||
<include base="wininet_winetest">.</include>
|
||||
<define name="__ROS_LONG64__" />
|
||||
<define name="__ROS_LONG64__" />
|
||||
<library>wine</library>
|
||||
<library>wininet</library>
|
||||
<library>ws2_32</library>
|
||||
<library>advapi32</library>
|
||||
<library>ntdll</library>
|
||||
<file>ftp.c</file>
|
||||
<file>generated.c</file>
|
||||
|
||||
Reference in New Issue
Block a user