wininet: Return error directly from HTTP_Connect.
This commit is contained in:
parent
e1958a67d6
commit
b73e31c659
|
@ -3880,7 +3880,7 @@ BOOL WINAPI HttpSendRequestExA(HINTERNET hRequest,
|
|||
header = HeapAlloc(GetProcessHeap(),0,headerlen*sizeof(WCHAR));
|
||||
if (!(BuffersInW.lpcszHeader = header))
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
||||
SetLastError(ERROR_OUTOFMEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
BuffersInW.dwHeadersLength = MultiByteToWideChar(CP_ACP, 0,
|
||||
|
@ -4203,30 +4203,25 @@ static const object_vtbl_t HTTPSESSIONVtbl = {
|
|||
* NULL on failure
|
||||
*
|
||||
*/
|
||||
HINTERNET HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
|
||||
INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
|
||||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
|
||||
DWORD dwInternalFlags)
|
||||
DWORD HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
|
||||
INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
|
||||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
|
||||
DWORD dwInternalFlags, HINTERNET *ret)
|
||||
{
|
||||
http_session_t *lpwhs = NULL;
|
||||
HINTERNET handle = NULL;
|
||||
DWORD res = ERROR_SUCCESS;
|
||||
|
||||
TRACE("-->\n");
|
||||
|
||||
if (!lpszServerName || !lpszServerName[0])
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
|
||||
goto lerror;
|
||||
}
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert( hIC->hdr.htype == WH_HINIT );
|
||||
|
||||
lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(http_session_t));
|
||||
if (NULL == lpwhs)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
||||
goto lerror;
|
||||
}
|
||||
if (!lpwhs)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
/*
|
||||
* According to my tests. The name is not resolved until a request is sent
|
||||
|
@ -4248,8 +4243,8 @@ HINTERNET HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
|
|||
if (NULL == handle)
|
||||
{
|
||||
ERR("Failed to alloc handle\n");
|
||||
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
||||
goto lerror;
|
||||
res = ERROR_OUTOFMEMORY;
|
||||
goto lerror;
|
||||
}
|
||||
|
||||
if(hIC->lpszProxy && hIC->dwAccessType == INTERNET_OPEN_TYPE_PROXY) {
|
||||
|
@ -4288,7 +4283,10 @@ lerror:
|
|||
*/
|
||||
|
||||
TRACE("%p --> %p (%p)\n", hIC, handle, lpwhs);
|
||||
return handle;
|
||||
|
||||
if(res == ERROR_SUCCESS)
|
||||
*ret = handle;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -949,6 +949,7 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
|
|||
{
|
||||
appinfo_t *hIC;
|
||||
HINTERNET rc = NULL;
|
||||
DWORD res = ERROR_SUCCESS;
|
||||
|
||||
TRACE("(%p, %s, %i, %s, %s, %i, %i, %lx)\n", hInternet, debugstr_w(lpszServerName),
|
||||
nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword),
|
||||
|
@ -956,16 +957,14 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
|
|||
|
||||
if (!lpszServerName)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Clear any error information */
|
||||
INTERNET_SetLastError(0);
|
||||
hIC = (appinfo_t*)WININET_GetObject( hInternet );
|
||||
if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INVALID_HANDLE);
|
||||
res = ERROR_INVALID_HANDLE;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
|
@ -974,11 +973,13 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
|
|||
case INTERNET_SERVICE_FTP:
|
||||
rc = FTP_Connect(hIC, lpszServerName, nServerPort,
|
||||
lpszUserName, lpszPassword, dwFlags, dwContext, 0);
|
||||
if(!rc)
|
||||
res = INTERNET_GetLastError();
|
||||
break;
|
||||
|
||||
case INTERNET_SERVICE_HTTP:
|
||||
rc = HTTP_Connect(hIC, lpszServerName, nServerPort,
|
||||
lpszUserName, lpszPassword, dwFlags, dwContext, 0);
|
||||
res = HTTP_Connect(hIC, lpszServerName, nServerPort,
|
||||
lpszUserName, lpszPassword, dwFlags, dwContext, 0, &rc);
|
||||
break;
|
||||
|
||||
case INTERNET_SERVICE_GOPHER:
|
||||
|
@ -990,6 +991,7 @@ lend:
|
|||
WININET_Release( &hIC->hdr );
|
||||
|
||||
TRACE("returning %p\n", rc);
|
||||
SetLastError(res);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -2835,6 +2837,7 @@ static HINTERNET INTERNET_InternetOpenUrlW(appinfo_t *hIC, LPCWSTR lpszUrl,
|
|||
WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
|
||||
WCHAR password[1024], path[2048], extra[1024];
|
||||
HINTERNET client = NULL, client1 = NULL;
|
||||
DWORD res;
|
||||
|
||||
TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hIC, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
|
||||
dwHeadersLength, dwFlags, dwContext);
|
||||
|
@ -2882,10 +2885,12 @@ static HINTERNET INTERNET_InternetOpenUrlW(appinfo_t *hIC, LPCWSTR lpszUrl,
|
|||
if (urlComponents.nScheme == INTERNET_SCHEME_HTTPS) dwFlags |= INTERNET_FLAG_SECURE;
|
||||
|
||||
/* FIXME: should use pointers, not handles, as handles are not thread-safe */
|
||||
client = HTTP_Connect(hIC, hostName, urlComponents.nPort,
|
||||
userName, password, dwFlags, dwContext, INET_OPENURL);
|
||||
if(client == NULL)
|
||||
res = HTTP_Connect(hIC, hostName, urlComponents.nPort,
|
||||
userName, password, dwFlags, dwContext, INET_OPENURL, &client);
|
||||
if(res != ERROR_SUCCESS) {
|
||||
INTERNET_SetLastError(res);
|
||||
break;
|
||||
}
|
||||
|
||||
if (urlComponents.dwExtraInfoLength) {
|
||||
WCHAR *path_extra;
|
||||
|
|
|
@ -397,10 +397,10 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
|
|||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
|
||||
DWORD dwInternalFlags);
|
||||
|
||||
HINTERNET HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
|
||||
INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
|
||||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
|
||||
DWORD dwInternalFlags);
|
||||
DWORD HTTP_Connect(appinfo_t*,LPCWSTR,
|
||||
INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
|
||||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
|
||||
DWORD dwInternalFlags, HINTERNET*);
|
||||
|
||||
BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
|
||||
struct sockaddr *psa, socklen_t *sa_len);
|
||||
|
|
Loading…
Reference in New Issue