wininet: Make a function for resolving the server name for an HTTP request
and sending the appropriate callbacks and use it to remove some duplicated code.
This commit is contained in:
parent
4319ec6b83
commit
72575a06ca
|
@ -964,6 +964,31 @@ static BOOL HTTP_DealWithProxy( LPWININETAPPINFOW hIC,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL HTTP_ResolveName(LPWININETHTTPREQW lpwhr)
|
||||||
|
{
|
||||||
|
char szaddr[32];
|
||||||
|
LPWININETHTTPSESSIONW lpwhs = lpwhr->lpHttpSession;
|
||||||
|
|
||||||
|
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||||
|
INTERNET_STATUS_RESOLVING_NAME,
|
||||||
|
lpwhs->lpszServerName,
|
||||||
|
strlenW(lpwhs->lpszServerName)+1);
|
||||||
|
|
||||||
|
if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
|
||||||
|
&lpwhs->socketAddress))
|
||||||
|
{
|
||||||
|
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inet_ntop(lpwhs->socketAddress.sin_family, &lpwhs->socketAddress.sin_addr,
|
||||||
|
szaddr, sizeof(szaddr));
|
||||||
|
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||||
|
INTERNET_STATUS_NAME_RESOLVED,
|
||||||
|
szaddr, strlen(szaddr)+1);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* HTTP_HttpOpenRequestW (internal)
|
* HTTP_HttpOpenRequestW (internal)
|
||||||
*
|
*
|
||||||
|
@ -988,7 +1013,6 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
|
||||||
static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0};
|
static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0};
|
||||||
DWORD len;
|
DWORD len;
|
||||||
LPHTTPHEADERW Host;
|
LPHTTPHEADERW Host;
|
||||||
char szaddr[32];
|
|
||||||
|
|
||||||
TRACE("-->\n");
|
TRACE("-->\n");
|
||||||
|
|
||||||
|
@ -1135,29 +1159,12 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
|
||||||
* A STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on windows
|
* A STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on windows
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
if (!HTTP_ResolveName(lpwhr))
|
||||||
* According to my tests. The name is not resolved until a request is Opened
|
|
||||||
*/
|
|
||||||
INTERNET_SendCallback(&lpwhr->hdr, dwContext,
|
|
||||||
INTERNET_STATUS_RESOLVING_NAME,
|
|
||||||
lpwhs->lpszServerName,
|
|
||||||
strlenW(lpwhs->lpszServerName)+1);
|
|
||||||
|
|
||||||
if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
|
|
||||||
&lpwhs->socketAddress))
|
|
||||||
{
|
{
|
||||||
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
|
|
||||||
InternetCloseHandle( handle );
|
InternetCloseHandle( handle );
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
goto lend;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inet_ntop(lpwhs->socketAddress.sin_family, &lpwhs->socketAddress.sin_addr,
|
|
||||||
szaddr, sizeof(szaddr));
|
|
||||||
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
|
|
||||||
INTERNET_STATUS_NAME_RESOLVED,
|
|
||||||
szaddr, strlen(szaddr)+1);
|
|
||||||
|
|
||||||
lend:
|
lend:
|
||||||
if( lpwhr )
|
if( lpwhr )
|
||||||
WININET_Release( &lpwhr->hdr );
|
WININET_Release( &lpwhr->hdr );
|
||||||
|
@ -1933,7 +1940,6 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl)
|
||||||
LPWININETHTTPSESSIONW lpwhs = lpwhr->lpHttpSession;
|
LPWININETHTTPSESSIONW lpwhs = lpwhr->lpHttpSession;
|
||||||
LPWININETAPPINFOW hIC = lpwhs->lpAppInfo;
|
LPWININETAPPINFOW hIC = lpwhs->lpAppInfo;
|
||||||
WCHAR path[2048];
|
WCHAR path[2048];
|
||||||
char szaddr[32];
|
|
||||||
|
|
||||||
if(lpszUrl[0]=='/')
|
if(lpszUrl[0]=='/')
|
||||||
{
|
{
|
||||||
|
@ -2090,23 +2096,8 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl)
|
||||||
lpwhs->lpszUserName = WININET_strdupW(userName);
|
lpwhs->lpszUserName = WININET_strdupW(userName);
|
||||||
lpwhs->nServerPort = urlComponents.nPort;
|
lpwhs->nServerPort = urlComponents.nPort;
|
||||||
|
|
||||||
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
|
if (!HTTP_ResolveName(lpwhr))
|
||||||
INTERNET_STATUS_RESOLVING_NAME,
|
|
||||||
lpwhs->lpszServerName,
|
|
||||||
strlenW(lpwhs->lpszServerName)+1);
|
|
||||||
|
|
||||||
if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
|
|
||||||
&lpwhs->socketAddress))
|
|
||||||
{
|
|
||||||
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
inet_ntop(lpwhs->socketAddress.sin_family, &lpwhs->socketAddress.sin_addr,
|
|
||||||
szaddr, sizeof(szaddr));
|
|
||||||
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
|
|
||||||
INTERNET_STATUS_NAME_RESOLVED,
|
|
||||||
szaddr, strlen(szaddr)+1);
|
|
||||||
|
|
||||||
NETCON_close(&lpwhr->netConnection);
|
NETCON_close(&lpwhr->netConnection);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue