Commit f57360af authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

wininet: Return correct errors in InternetConnectW

parent 336e67e2
......@@ -812,17 +812,26 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
DWORD dwService, DWORD dwFlags, DWORD dwContext)
{
LPWININETAPPINFOW hIC;
HINTERNET rc = (HINTERNET) NULL;
HINTERNET rc = NULL;
TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet, debugstr_w(lpszServerName),
nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword),
dwService, dwFlags, dwContext);
if (!lpszServerName)
{
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
/* Clear any error information */
INTERNET_SetLastError(0);
hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
{
SetLastError(ERROR_INVALID_HANDLE);
goto lend;
}
switch (dwService)
{
......
......@@ -119,8 +119,36 @@ static void test_get_cookie(void)
ret ? "TRUE" : "FALSE", GetLastError());
}
static void test_null(void)
{
HINTERNET hi, hc;
static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
ok(hi != NULL, "open failed\n");
hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
ok(hc == NULL, "connect failed\n");
hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
ok(hc == NULL, "connect failed\n");
hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
ok(hc == NULL, "connect failed\n");
hc = InternetConnectW(NULL, szServer, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
ok(hc == NULL, "connect failed\n");
InternetCloseHandle(hi);
}
START_TEST(internet)
{
InternetQueryOptionA_test();
test_get_cookie();
test_null();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment