- Sync wininet to Wine HEAD

- Remove a change from our "wininet_ros.diff" file, which has been applied to Wine as well in the meantime
- Eliminate a warning in our "inet_ntop.c" (ROS glue code)

svn path=/trunk/; revision=35943
This commit is contained in:
Colin Finck 2008-09-04 18:37:34 +00:00
parent 0728b1b869
commit fac1457233
12 changed files with 611 additions and 503 deletions

View file

@ -631,10 +631,10 @@ BOOL WINAPI InternetClearAllPerSiteCookieDecisions( VOID )
* *
* See InternetEnumPerSiteCookieDecisionW. * See InternetEnumPerSiteCookieDecisionW.
*/ */
BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, unsigned long *pcSiteNameSize, BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, ULONG *pcSiteNameSize,
unsigned long *pdwDecision, unsigned long dwIndex ) ULONG *pdwDecision, ULONG dwIndex )
{ {
FIXME("(%s, %p, %p, 0x%08lx) stub\n", FIXME("(%s, %p, %p, 0x%08x) stub\n",
debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex); debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
return FALSE; return FALSE;
} }
@ -649,10 +649,10 @@ BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, unsigned long
* FALSE on failure * FALSE on failure
* *
*/ */
BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, unsigned long *pcSiteNameSize, BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, ULONG *pcSiteNameSize,
unsigned long *pdwDecision, unsigned long dwIndex ) ULONG *pdwDecision, ULONG dwIndex )
{ {
FIXME("(%s, %p, %p, 0x%08lx) stub\n", FIXME("(%s, %p, %p, 0x%08x) stub\n",
debugstr_w(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex); debugstr_w(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
return FALSE; return FALSE;
} }
@ -660,7 +660,7 @@ BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, unsigned lon
/*********************************************************************** /***********************************************************************
* InternetGetPerSiteCookieDecisionA (WININET.@) * InternetGetPerSiteCookieDecisionA (WININET.@)
*/ */
BOOL WINAPI InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName, unsigned long *pResult ) BOOL WINAPI InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName, ULONG *pResult )
{ {
FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName), pResult); FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName), pResult);
return FALSE; return FALSE;
@ -669,7 +669,7 @@ BOOL WINAPI InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName, unsigned lon
/*********************************************************************** /***********************************************************************
* InternetGetPerSiteCookieDecisionW (WININET.@) * InternetGetPerSiteCookieDecisionW (WININET.@)
*/ */
BOOL WINAPI InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName, unsigned long *pResult ) BOOL WINAPI InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName, ULONG *pResult )
{ {
FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName), pResult); FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName), pResult);
return FALSE; return FALSE;

View file

@ -1227,8 +1227,7 @@ static DWORD FTPFILE_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
FIXME("Not implemented option %d\n", option); return INET_QueryOption(option, buffer, size, unicode);
return ERROR_INTERNET_INVALID_OPTION;
} }
static DWORD FTPFILE_ReadFile(WININETHANDLEHEADER *hdr, void *buffer, DWORD size, DWORD *read) static DWORD FTPFILE_ReadFile(WININETHANDLEHEADER *hdr, void *buffer, DWORD size, DWORD *read)
@ -1553,6 +1552,7 @@ static BOOL FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile,
&iar, sizeof(INTERNET_ASYNC_RESULT)); &iar, sizeof(INTERNET_ASYNC_RESULT));
} }
if (!bSuccess) DeleteFileW(lpszNewFile);
return bSuccess; return bSuccess;
} }
@ -2194,8 +2194,7 @@ static DWORD FTPSESSION_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
FIXME("Not implemented option %d\n", option); return INET_QueryOption(option, buffer, size, unicode);
return ERROR_INTERNET_INVALID_OPTION;
} }
static const HANDLEHEADERVtbl FTPSESSIONVtbl = { static const HANDLEHEADERVtbl FTPSESSIONVtbl = {
@ -3275,8 +3274,7 @@ static DWORD FTPFINDNEXT_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, voi
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
FIXME("Not implemented option %d\n", option); return INET_QueryOption(option, buffer, size, unicode);
return ERROR_INTERNET_INVALID_OPTION;
} }
static DWORD FTPFINDNEXT_FindNextFileW(WININETHANDLEHEADER *hdr, void *data) static DWORD FTPFINDNEXT_FindNextFileW(WININETHANDLEHEADER *hdr, void *data)

View file

@ -1348,6 +1348,8 @@ static BOOL HTTP_ResolveName(LPWININETHTTPREQW lpwhr)
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_NAME_RESOLVED, INTERNET_STATUS_NAME_RESOLVED,
szaddr, strlen(szaddr)+1); szaddr, strlen(szaddr)+1);
TRACE("resolved %s to %s\n", debugstr_w(lpwhs->lpszServerName), szaddr);
return TRUE; return TRUE;
} }
@ -1394,7 +1396,6 @@ static void HTTPREQ_Destroy(WININETHANDLEHEADER *hdr)
static void HTTPREQ_CloseConnection(WININETHANDLEHEADER *hdr) static void HTTPREQ_CloseConnection(WININETHANDLEHEADER *hdr)
{ {
LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hdr; LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hdr;
LPWININETHTTPSESSIONW lpwhs = NULL;
TRACE("%p\n",lpwhr); TRACE("%p\n",lpwhr);
@ -1426,8 +1427,6 @@ static void HTTPREQ_CloseConnection(WININETHANDLEHEADER *hdr)
lpwhr->pProxyAuthInfo = NULL; lpwhr->pProxyAuthInfo = NULL;
} }
lpwhs = lpwhr->lpHttpSession;
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CLOSING_CONNECTION, 0, 0); INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
@ -1456,14 +1455,20 @@ static DWORD HTTPREQ_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b
WCHAR url[INTERNET_MAX_URL_LENGTH]; WCHAR url[INTERNET_MAX_URL_LENGTH];
HTTPHEADERW *host; HTTPHEADERW *host;
DWORD len; DWORD len;
WCHAR *pch;
static const WCHAR formatW[] = {'h','t','t','p',':','/','/','%','s','%','s',0}; static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0};
static const WCHAR hostW[] = {'H','o','s','t',0}; static const WCHAR hostW[] = {'H','o','s','t',0};
TRACE("INTERNET_OPTION_URL\n"); TRACE("INTERNET_OPTION_URL\n");
host = HTTP_GetHeader(req, hostW); host = HTTP_GetHeader(req, hostW);
sprintfW(url, formatW, host->lpszValue, req->lpszPath); strcpyW(url, httpW);
strcatW(url, host->lpszValue);
if (NULL != (pch = strchrW(url + strlenW(httpW), ':')))
*pch = 0;
strcatW(url, req->lpszPath);
TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url)); TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url));
if(unicode) { if(unicode) {
@ -1576,8 +1581,7 @@ static DWORD HTTPREQ_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b
} }
} }
FIXME("Not implemented option %d\n", option); return INET_QueryOption(option, buffer, size, unicode);
return ERROR_INTERNET_INVALID_OPTION;
} }
static DWORD HTTPREQ_SetOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD size) static DWORD HTTPREQ_SetOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD size)
@ -1886,13 +1890,10 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
{ {
LPWININETAPPINFOW hIC = NULL; LPWININETAPPINFOW hIC = NULL;
LPWININETHTTPREQW lpwhr; LPWININETHTTPREQW lpwhr;
LPWSTR lpszCookies; LPWSTR lpszHostName = NULL;
LPWSTR lpszUrl = NULL;
DWORD nCookieSize;
HINTERNET handle = NULL; HINTERNET handle = NULL;
static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0}; static const WCHAR szHostForm[] = {'%','s',':','%','u',0};
DWORD len; DWORD len;
LPHTTPHEADERW Host;
TRACE("-->\n"); TRACE("-->\n");
@ -1917,6 +1918,14 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
lpwhr->lpHttpSession = lpwhs; lpwhr->lpHttpSession = lpwhs;
list_add_head( &lpwhs->hdr.children, &lpwhr->hdr.entry ); list_add_head( &lpwhs->hdr.children, &lpwhr->hdr.entry );
lpszHostName = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) *
(strlenW(lpwhs->lpszHostName) + 7 /* length of ":65535" + 1 */));
if (NULL == lpszHostName)
{
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
goto lend;
}
handle = WININET_AllocHandle( &lpwhr->hdr ); handle = WININET_AllocHandle( &lpwhr->hdr );
if (NULL == handle) if (NULL == handle)
{ {
@ -1971,7 +1980,17 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
else else
lpwhr->lpszVersion = WININET_strdupW(g_szHttp1_1); lpwhr->lpszVersion = WININET_strdupW(g_szHttp1_1);
HTTP_ProcessHeader(lpwhr, szHost, lpwhs->lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ); if (lpwhs->nHostPort != INTERNET_INVALID_PORT_NUMBER &&
lpwhs->nHostPort != INTERNET_DEFAULT_HTTP_PORT &&
lpwhs->nHostPort != INTERNET_DEFAULT_HTTPS_PORT)
{
sprintfW(lpszHostName, szHostForm, lpwhs->lpszHostName, lpwhs->nHostPort);
HTTP_ProcessHeader(lpwhr, szHost, lpszHostName,
HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ);
}
else
HTTP_ProcessHeader(lpwhr, szHost, lpwhs->lpszHostName,
HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ);
if (lpwhs->nServerPort == INTERNET_INVALID_PORT_NUMBER) if (lpwhs->nServerPort == INTERNET_INVALID_PORT_NUMBER)
lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ? lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ?
@ -1986,47 +2005,12 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
if (NULL != hIC->lpszProxy && hIC->lpszProxy[0] != 0) if (NULL != hIC->lpszProxy && hIC->lpszProxy[0] != 0)
HTTP_DealWithProxy( hIC, lpwhs, lpwhr ); HTTP_DealWithProxy( hIC, lpwhs, lpwhr );
Host = HTTP_GetHeader(lpwhr,szHost);
len = lstrlenW(Host->lpszValue) + strlenW(szUrlForm);
lpszUrl = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
sprintfW( lpszUrl, szUrlForm, Host->lpszValue );
if (!(lpwhr->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES) &&
InternetGetCookieW(lpszUrl, NULL, NULL, &nCookieSize))
{
int cnt = 0;
static const WCHAR szCookie[] = {'C','o','o','k','i','e',':',' ',0};
static const WCHAR szcrlf[] = {'\r','\n',0};
lpszCookies = HeapAlloc(GetProcessHeap(), 0, (nCookieSize + 1 + 8)*sizeof(WCHAR));
cnt += sprintfW(lpszCookies, szCookie);
InternetGetCookieW(lpszUrl, NULL, lpszCookies + cnt, &nCookieSize);
strcatW(lpszCookies, szcrlf);
HTTP_HttpAddRequestHeadersW(lpwhr, lpszCookies, strlenW(lpszCookies),
HTTP_ADDREQ_FLAG_ADD);
HeapFree(GetProcessHeap(), 0, lpszCookies);
}
HeapFree(GetProcessHeap(), 0, lpszUrl);
INTERNET_SendCallback(&lpwhs->hdr, dwContext, INTERNET_SendCallback(&lpwhs->hdr, dwContext,
INTERNET_STATUS_HANDLE_CREATED, &handle, INTERNET_STATUS_HANDLE_CREATED, &handle,
sizeof(handle)); sizeof(handle));
/*
* A STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on windows
*/
if (!HTTP_ResolveName(lpwhr))
{
InternetCloseHandle( handle );
handle = NULL;
}
lend: lend:
HeapFree(GetProcessHeap(), 0, lpszHostName);
if( lpwhr ) if( lpwhr )
WININET_Release( &lpwhr->hdr ); WININET_Release( &lpwhr->hdr );
@ -3027,17 +3011,16 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl)
if (!using_proxy) if (!using_proxy)
{ {
HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName); if (strcmpiW(lpwhs->lpszServerName, hostName) || lpwhs->nServerPort != urlComponents.nPort)
lpwhs->lpszServerName = WININET_strdupW(hostName); {
lpwhs->nServerPort = urlComponents.nPort; HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName);
lpwhs->lpszServerName = WININET_strdupW(hostName);
lpwhs->nServerPort = urlComponents.nPort;
if (!HTTP_ResolveName(lpwhr)) NETCON_close(&lpwhr->netConnection);
return FALSE; if (!HTTP_ResolveName(lpwhr)) return FALSE;
if (!NETCON_init(&lpwhr->netConnection, lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE)) return FALSE;
NETCON_close(&lpwhr->netConnection); }
if (!NETCON_init(&lpwhr->netConnection,lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE))
return FALSE;
} }
else else
TRACE("Redirect through proxy\n"); TRACE("Redirect through proxy\n");
@ -3139,6 +3122,37 @@ static BOOL HTTP_SecureProxyConnect(LPWININETHTTPREQW lpwhr)
return TRUE; return TRUE;
} }
static void HTTP_InsertCookies(LPWININETHTTPREQW lpwhr)
{
static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0};
LPWSTR lpszCookies, lpszUrl = NULL;
DWORD nCookieSize, size;
LPHTTPHEADERW Host = HTTP_GetHeader(lpwhr,szHost);
size = (strlenW(Host->lpszValue) + strlenW(szUrlForm)) * sizeof(WCHAR);
if (!(lpszUrl = HeapAlloc(GetProcessHeap(), 0, size))) return;
sprintfW( lpszUrl, szUrlForm, Host->lpszValue );
if (InternetGetCookieW(lpszUrl, NULL, NULL, &nCookieSize))
{
int cnt = 0;
static const WCHAR szCookie[] = {'C','o','o','k','i','e',':',' ',0};
static const WCHAR szcrlf[] = {'\r','\n',0};
size = sizeof(szCookie) + nCookieSize * sizeof(WCHAR) + sizeof(szcrlf);
if ((lpszCookies = HeapAlloc(GetProcessHeap(), 0, size)))
{
cnt += sprintfW(lpszCookies, szCookie);
InternetGetCookieW(lpszUrl, NULL, lpszCookies + cnt, &nCookieSize);
strcatW(lpszCookies, szcrlf);
HTTP_HttpAddRequestHeadersW(lpwhr, lpszCookies, strlenW(lpszCookies), HTTP_ADDREQ_FLAG_ADD);
HeapFree(GetProcessHeap(), 0, lpszCookies);
}
}
HeapFree(GetProcessHeap(), 0, lpszUrl);
}
/*********************************************************************** /***********************************************************************
* HTTP_HttpSendRequestW (internal) * HTTP_HttpSendRequestW (internal)
* *
@ -3159,7 +3173,6 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
INT responseLen; INT responseLen;
BOOL loop_next; BOOL loop_next;
INTERNET_ASYNC_RESULT iar; INTERNET_ASYNC_RESULT iar;
static const WCHAR szClose[] = { 'C','l','o','s','e',0 };
static const WCHAR szPost[] = { 'P','O','S','T',0 }; static const WCHAR szPost[] = { 'P','O','S','T',0 };
static const WCHAR szContentLength[] = static const WCHAR szContentLength[] =
{ 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0 }; { 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0 };
@ -3169,9 +3182,6 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
assert(lpwhr->hdr.htype == WH_HHTTPREQ); assert(lpwhr->hdr.htype == WH_HHTTPREQ);
/* Clear any error information */
INTERNET_SetLastError(0);
/* if the verb is NULL default to GET */ /* if the verb is NULL default to GET */
if (!lpwhr->lpszVerb) if (!lpwhr->lpszVerb)
lpwhr->lpszVerb = WININET_strdupW(szGET); lpwhr->lpszVerb = WININET_strdupW(szGET);
@ -3194,6 +3204,17 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
HTTP_HttpAddRequestHeadersW(lpwhr, agent_header, strlenW(agent_header), HTTP_ADDREQ_FLAG_ADD_IF_NEW); HTTP_HttpAddRequestHeadersW(lpwhr, agent_header, strlenW(agent_header), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
HeapFree(GetProcessHeap(), 0, agent_header); HeapFree(GetProcessHeap(), 0, agent_header);
} }
if (lpwhr->hdr.dwFlags & INTERNET_FLAG_PRAGMA_NOCACHE)
{
static const WCHAR pragma_nocache[] = {'P','r','a','g','m','a',':',' ','n','o','-','c','a','c','h','e','\r','\n',0};
HTTP_HttpAddRequestHeadersW(lpwhr, pragma_nocache, strlenW(pragma_nocache), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
}
if ((lpwhr->hdr.dwFlags & INTERNET_FLAG_NO_CACHE_WRITE) && !strcmpW(lpwhr->lpszVerb, szPost))
{
static const WCHAR cache_control[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l',':',
' ','n','o','-','c','a','c','h','e','\r','\n',0};
HTTP_HttpAddRequestHeadersW(lpwhr, cache_control, strlenW(cache_control), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
}
do do
{ {
@ -3214,13 +3235,16 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
} }
HTTP_FixURL(lpwhr); HTTP_FixURL(lpwhr);
HTTP_ProcessHeader(lpwhr, szConnection, if (lpwhr->hdr.dwFlags & INTERNET_FLAG_KEEP_CONNECTION)
lpwhr->hdr.dwFlags & INTERNET_FLAG_KEEP_CONNECTION ? szKeepAlive : szClose, {
HTTP_ADDHDR_FLAG_REQ | HTTP_ADDHDR_FLAG_REPLACE); HTTP_ProcessHeader(lpwhr, szConnection, szKeepAlive, HTTP_ADDHDR_FLAG_REQ | HTTP_ADDHDR_FLAG_REPLACE);
}
HTTP_InsertAuthorization(lpwhr, lpwhr->pAuthInfo, szAuthorization); HTTP_InsertAuthorization(lpwhr, lpwhr->pAuthInfo, szAuthorization);
HTTP_InsertAuthorization(lpwhr, lpwhr->pProxyAuthInfo, szProxy_Authorization); HTTP_InsertAuthorization(lpwhr, lpwhr->pProxyAuthInfo, szProxy_Authorization);
if (!(lpwhr->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES))
HTTP_InsertCookies(lpwhr);
/* add the headers the caller supplied */ /* add the headers the caller supplied */
if( lpszHeaders && dwHeaderLength ) if( lpszHeaders && dwHeaderLength )
{ {
@ -3413,6 +3437,7 @@ lend:
sizeof(INTERNET_ASYNC_RESULT)); sizeof(INTERNET_ASYNC_RESULT));
TRACE("<--\n"); TRACE("<--\n");
if (bSuccess) INTERNET_SetLastError(ERROR_SUCCESS);
return bSuccess; return bSuccess;
} }
@ -3451,8 +3476,7 @@ static DWORD HTTPSESSION_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, voi
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
FIXME("Not implemented option %d\n", option); return INET_QueryOption(option, buffer, size, unicode);
return ERROR_INTERNET_INVALID_OPTION;
} }
static const HANDLEHEADERVtbl HTTPSESSIONVtbl = { static const HANDLEHEADERVtbl HTTPSESSIONVtbl = {
@ -3598,6 +3622,7 @@ static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr)
bSuccess = TRUE; bSuccess = TRUE;
goto lend; goto lend;
} }
if (!HTTP_ResolveName(lpwhr)) goto lend;
lpwhs = lpwhr->lpHttpSession; lpwhs = lpwhr->lpHttpSession;
@ -3612,7 +3637,7 @@ static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr)
if (!NETCON_create(&lpwhr->netConnection, lpwhs->socketAddress.sin_family, if (!NETCON_create(&lpwhr->netConnection, lpwhs->socketAddress.sin_family,
SOCK_STREAM, 0)) SOCK_STREAM, 0))
{ {
WARN("Socket creation failed\n"); WARN("Socket creation failed: %u\n", INTERNET_GetLastError());
goto lend; goto lend;
} }
@ -3813,7 +3838,10 @@ lend:
if (bSuccess) if (bSuccess)
return rc; return rc;
else else
{
HeapFree(GetProcessHeap(), 0, lpszRawHeaders);
return 0; return 0;
}
} }
@ -4026,7 +4054,9 @@ static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v
BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr) BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr)
{ {
WCHAR szVersion[10]; WCHAR szVersion[10];
WCHAR szConnectionResponse[20];
DWORD dwBufferSize = sizeof(szVersion); DWORD dwBufferSize = sizeof(szVersion);
BOOL keepalive = FALSE;
TRACE("\n"); TRACE("\n");
@ -4036,15 +4066,19 @@ BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr)
&dwBufferSize, NULL) || &dwBufferSize, NULL) ||
strcmpiW(szVersion, g_szHttp1_1)) strcmpiW(szVersion, g_szHttp1_1))
{ {
WCHAR szConnectionResponse[20]; keepalive = TRUE;
dwBufferSize = sizeof(szConnectionResponse); }
if ((!HTTP_HttpQueryInfoW(lpwhr, HTTP_QUERY_CONNECTION, szConnectionResponse, &dwBufferSize, NULL) ||
strcmpiW(szConnectionResponse, szKeepAlive)) && dwBufferSize = sizeof(szConnectionResponse);
(!HTTP_HttpQueryInfoW(lpwhr, HTTP_QUERY_PROXY_CONNECTION, szConnectionResponse, &dwBufferSize, NULL) || if (HTTP_HttpQueryInfoW(lpwhr, HTTP_QUERY_PROXY_CONNECTION, szConnectionResponse, &dwBufferSize, NULL) ||
strcmpiW(szConnectionResponse, szKeepAlive))) HTTP_HttpQueryInfoW(lpwhr, HTTP_QUERY_CONNECTION, szConnectionResponse, &dwBufferSize, NULL))
{ {
HTTPREQ_CloseConnection(&lpwhr->hdr); keepalive = !strcmpiW(szConnectionResponse, szKeepAlive);
} }
if (!keepalive)
{
HTTPREQ_CloseConnection(&lpwhr->hdr);
} }
/* FIXME: store data in the URL cache here */ /* FIXME: store data in the URL cache here */
@ -4142,6 +4176,9 @@ static BOOL HTTP_DeleteCustomHeader(LPWININETHTTPREQW lpwhr, DWORD index)
return FALSE; return FALSE;
lpwhr->nCustHeaders--; lpwhr->nCustHeaders--;
HeapFree(GetProcessHeap(), 0, lpwhr->pCustHeaders[index].lpszField);
HeapFree(GetProcessHeap(), 0, lpwhr->pCustHeaders[index].lpszValue);
memmove( &lpwhr->pCustHeaders[index], &lpwhr->pCustHeaders[index+1], memmove( &lpwhr->pCustHeaders[index], &lpwhr->pCustHeaders[index+1],
(lpwhr->nCustHeaders - index)* sizeof(HTTPHEADERW) ); (lpwhr->nCustHeaders - index)* sizeof(HTTPHEADERW) );
memset( &lpwhr->pCustHeaders[lpwhr->nCustHeaders], 0, sizeof(HTTPHEADERW) ); memset( &lpwhr->pCustHeaders[lpwhr->nCustHeaders], 0, sizeof(HTTPHEADERW) );

View file

@ -39,7 +39,10 @@
*/ */
static const char *inet_ntop4(const u_char *src, char *dst, size_t size); static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
#ifdef INET6
static const char *inet_ntop6(const u_char *src, char *dst, size_t size); static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
#endif
/* char * /* char *
* inet_ntop(af, src, dst, size) * inet_ntop(af, src, dst, size)

View file

@ -181,9 +181,13 @@ BOOL WININET_Release( LPWININETHANDLEHEADER info )
TRACE( "closing connection %p\n", info); TRACE( "closing connection %p\n", info);
info->vtbl->CloseConnection( info ); info->vtbl->CloseConnection( info );
} }
INTERNET_SendCallback(info, info->dwContext, /* Don't send a callback if this is a session handle created with InternetOpenUrl */
INTERNET_STATUS_HANDLE_CLOSING, &info->hInternet, if (info->htype != WH_HHTTPSESSION || !(info->dwInternalFlags & INET_OPENURL))
sizeof(HINTERNET)); {
INTERNET_SendCallback(info, info->dwContext,
INTERNET_STATUS_HANDLE_CLOSING, &info->hInternet,
sizeof(HINTERNET));
}
TRACE( "destroying object %p\n", info); TRACE( "destroying object %p\n", info);
if ( info->htype != WH_HINIT ) if ( info->htype != WH_HINIT )
list_remove( &info->entry ); list_remove( &info->entry );
@ -491,6 +495,8 @@ static VOID APPINFO_Destroy(WININETHANDLEHEADER *hdr)
static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode) static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
{ {
LPWININETAPPINFOW ai = (LPWININETAPPINFOW)hdr;
switch(option) { switch(option) {
case INTERNET_OPTION_HANDLE_TYPE: case INTERNET_OPTION_HANDLE_TYPE:
TRACE("INTERNET_OPTION_HANDLE_TYPE\n"); TRACE("INTERNET_OPTION_HANDLE_TYPE\n");
@ -501,10 +507,98 @@ static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b
*size = sizeof(DWORD); *size = sizeof(DWORD);
*(DWORD*)buffer = INTERNET_HANDLE_TYPE_INTERNET; *(DWORD*)buffer = INTERNET_HANDLE_TYPE_INTERNET;
return ERROR_SUCCESS; return ERROR_SUCCESS;
case INTERNET_OPTION_USER_AGENT: {
DWORD bufsize;
TRACE("INTERNET_OPTION_USER_AGENT\n");
bufsize = *size;
if (unicode) {
*size = (strlenW(ai->lpszAgent) + 1) * sizeof(WCHAR);
if(!buffer || bufsize < *size)
return ERROR_INSUFFICIENT_BUFFER;
strcpyW(buffer, ai->lpszAgent);
}else {
*size = WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, NULL, 0, NULL, NULL);
if(!buffer || bufsize < *size)
return ERROR_INSUFFICIENT_BUFFER;
WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, buffer, *size, NULL, NULL);
}
return ERROR_SUCCESS;
} }
FIXME("Not implemented option %d\n", option); case INTERNET_OPTION_PROXY:
return ERROR_INTERNET_INVALID_OPTION; if (unicode) {
INTERNET_PROXY_INFOW *pi = (INTERNET_PROXY_INFOW *)buffer;
DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
LPWSTR proxy, proxy_bypass;
if (ai->lpszProxy)
proxyBytesRequired = (lstrlenW(ai->lpszProxy) + 1) * sizeof(WCHAR);
if (ai->lpszProxyBypass)
proxyBypassBytesRequired = (lstrlenW(ai->lpszProxyBypass) + 1) * sizeof(WCHAR);
if (*size < sizeof(INTERNET_PROXY_INFOW) + proxyBytesRequired + proxyBypassBytesRequired)
return ERROR_INSUFFICIENT_BUFFER;
proxy = (LPWSTR)((LPBYTE)buffer + sizeof(INTERNET_PROXY_INFOW));
proxy_bypass = (LPWSTR)((LPBYTE)buffer + sizeof(INTERNET_PROXY_INFOW) + proxyBytesRequired);
pi->dwAccessType = ai->dwAccessType;
pi->lpszProxy = NULL;
pi->lpszProxyBypass = NULL;
if (ai->lpszProxy) {
lstrcpyW(proxy, ai->lpszProxy);
pi->lpszProxy = proxy;
}
if (ai->lpszProxyBypass) {
lstrcpyW(proxy_bypass, ai->lpszProxyBypass);
pi->lpszProxyBypass = proxy_bypass;
}
*size = sizeof(INTERNET_PROXY_INFOW) + proxyBytesRequired + proxyBypassBytesRequired;
return ERROR_SUCCESS;
}else {
INTERNET_PROXY_INFOA *pi = (INTERNET_PROXY_INFOA *)buffer;
DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
LPSTR proxy, proxy_bypass;
if (ai->lpszProxy)
proxyBytesRequired = WideCharToMultiByte(CP_ACP, 0, ai->lpszProxy, -1, NULL, 0, NULL, NULL);
if (ai->lpszProxyBypass)
proxyBypassBytesRequired = WideCharToMultiByte(CP_ACP, 0, ai->lpszProxyBypass, -1,
NULL, 0, NULL, NULL);
if (*size < sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired + proxyBypassBytesRequired)
return ERROR_INSUFFICIENT_BUFFER;
proxy = (LPSTR)((LPBYTE)buffer + sizeof(INTERNET_PROXY_INFOA));
proxy_bypass = (LPSTR)((LPBYTE)buffer + sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired);
pi->dwAccessType = ai->dwAccessType;
pi->lpszProxy = NULL;
pi->lpszProxyBypass = NULL;
if (ai->lpszProxy) {
WideCharToMultiByte(CP_ACP, 0, ai->lpszProxy, -1, proxy, proxyBytesRequired, NULL, NULL);
pi->lpszProxy = proxy;
}
if (ai->lpszProxyBypass) {
WideCharToMultiByte(CP_ACP, 0, ai->lpszProxyBypass, -1, proxy_bypass,
proxyBypassBytesRequired, NULL, NULL);
pi->lpszProxyBypass = proxy_bypass;
}
*size = sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired + proxyBypassBytesRequired;
return ERROR_SUCCESS;
}
}
return INET_QueryOption(option, buffer, size, unicode);
} }
static const HANDLEHEADERVtbl APPINFOVtbl = { static const HANDLEHEADERVtbl APPINFOVtbl = {
@ -1046,14 +1140,14 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
/*********************************************************************** /***********************************************************************
* ConvertUrlComponentValue (Internal) * ConvertUrlComponentValue (Internal)
* *
* Helper function for InternetCrackUrlW * Helper function for InternetCrackUrlA
* *
*/ */
static void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen, static void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
LPWSTR lpwszComponent, DWORD dwwComponentLen, LPWSTR lpwszComponent, DWORD dwwComponentLen,
LPCSTR lpszStart, LPCWSTR lpwszStart) LPCSTR lpszStart, LPCWSTR lpwszStart)
{ {
TRACE("%p %d %p %d %p %p\n", lppszComponent, *dwComponentLen, lpwszComponent, dwwComponentLen, lpszStart, lpwszStart); TRACE("%p %d %p %d %p %p\n", *lppszComponent, *dwComponentLen, lpwszComponent, dwwComponentLen, lpszStart, lpwszStart);
if (*dwComponentLen != 0) if (*dwComponentLen != 0)
{ {
DWORD nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL); DWORD nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
@ -1087,9 +1181,13 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
{ {
DWORD nLength; DWORD nLength;
URL_COMPONENTSW UCW; URL_COMPONENTSW UCW;
WCHAR* lpwszUrl; BOOL ret = FALSE;
WCHAR *lpwszUrl, *hostname = NULL, *username = NULL, *password = NULL, *path = NULL,
*scheme = NULL, *extra = NULL;
TRACE("(%s %u %x %p)\n", debugstr_a(lpszUrl), dwUrlLength, dwFlags, lpUrlComponents); TRACE("(%s %u %x %p)\n",
lpszUrl ? debugstr_an(lpszUrl, dwUrlLength ? dwUrlLength : strlen(lpszUrl)) : "(null)",
dwUrlLength, dwFlags, lpUrlComponents);
if (!lpszUrl || !*lpszUrl || !lpUrlComponents || if (!lpszUrl || !*lpszUrl || !lpUrlComponents ||
lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSA)) lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSA))
@ -1111,53 +1209,92 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
memset(&UCW,0,sizeof(UCW)); memset(&UCW,0,sizeof(UCW));
UCW.dwStructSize = sizeof(URL_COMPONENTSW); UCW.dwStructSize = sizeof(URL_COMPONENTSW);
if(lpUrlComponents->dwHostNameLength!=0) if (lpUrlComponents->dwHostNameLength)
UCW.dwHostNameLength= lpUrlComponents->dwHostNameLength;
if(lpUrlComponents->dwUserNameLength!=0)
UCW.dwUserNameLength=lpUrlComponents->dwUserNameLength;
if(lpUrlComponents->dwPasswordLength!=0)
UCW.dwPasswordLength=lpUrlComponents->dwPasswordLength;
if(lpUrlComponents->dwUrlPathLength!=0)
UCW.dwUrlPathLength=lpUrlComponents->dwUrlPathLength;
if(lpUrlComponents->dwSchemeLength!=0)
UCW.dwSchemeLength=lpUrlComponents->dwSchemeLength;
if(lpUrlComponents->dwExtraInfoLength!=0)
UCW.dwExtraInfoLength=lpUrlComponents->dwExtraInfoLength;
if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
{ {
HeapFree(GetProcessHeap(), 0, lpwszUrl); UCW.dwHostNameLength = lpUrlComponents->dwHostNameLength;
return FALSE; if (lpUrlComponents->lpszHostName)
{
hostname = HeapAlloc(GetProcessHeap(), 0, UCW.dwHostNameLength * sizeof(WCHAR));
UCW.lpszHostName = hostname;
}
} }
if (lpUrlComponents->dwUserNameLength)
{
UCW.dwUserNameLength = lpUrlComponents->dwUserNameLength;
if (lpUrlComponents->lpszUserName)
{
username = HeapAlloc(GetProcessHeap(), 0, UCW.dwUserNameLength * sizeof(WCHAR));
UCW.lpszUserName = username;
}
}
if (lpUrlComponents->dwPasswordLength)
{
UCW.dwPasswordLength = lpUrlComponents->dwPasswordLength;
if (lpUrlComponents->lpszPassword)
{
password = HeapAlloc(GetProcessHeap(), 0, UCW.dwPasswordLength * sizeof(WCHAR));
UCW.lpszPassword = password;
}
}
if (lpUrlComponents->dwUrlPathLength)
{
UCW.dwUrlPathLength = lpUrlComponents->dwUrlPathLength;
if (lpUrlComponents->lpszUrlPath)
{
path = HeapAlloc(GetProcessHeap(), 0, UCW.dwUrlPathLength * sizeof(WCHAR));
UCW.lpszUrlPath = path;
}
}
if (lpUrlComponents->dwSchemeLength)
{
UCW.dwSchemeLength = lpUrlComponents->dwSchemeLength;
if (lpUrlComponents->lpszScheme)
{
scheme = HeapAlloc(GetProcessHeap(), 0, UCW.dwSchemeLength * sizeof(WCHAR));
UCW.lpszScheme = scheme;
}
}
if (lpUrlComponents->dwExtraInfoLength)
{
UCW.dwExtraInfoLength = lpUrlComponents->dwExtraInfoLength;
if (lpUrlComponents->lpszExtraInfo)
{
extra = HeapAlloc(GetProcessHeap(), 0, UCW.dwExtraInfoLength * sizeof(WCHAR));
UCW.lpszExtraInfo = extra;
}
}
if ((ret = InternetCrackUrlW(lpwszUrl, nLength, dwFlags, &UCW)))
{
ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
UCW.lpszHostName, UCW.dwHostNameLength, lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
UCW.lpszUserName, UCW.dwUserNameLength, lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
UCW.lpszPassword, UCW.dwPasswordLength, lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
UCW.lpszUrlPath, UCW.dwUrlPathLength, lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
UCW.lpszScheme, UCW.dwSchemeLength, lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
UCW.lpszExtraInfo, UCW.dwExtraInfoLength, lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength, lpUrlComponents->nScheme = UCW.nScheme;
UCW.lpszHostName, UCW.dwHostNameLength, lpUrlComponents->nPort = UCW.nPort;
lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength, TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
UCW.lpszUserName, UCW.dwUserNameLength, debugstr_an(lpUrlComponents->lpszScheme, lpUrlComponents->dwSchemeLength),
lpszUrl, lpwszUrl); debugstr_an(lpUrlComponents->lpszHostName, lpUrlComponents->dwHostNameLength),
ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength, debugstr_an(lpUrlComponents->lpszUrlPath, lpUrlComponents->dwUrlPathLength),
UCW.lpszPassword, UCW.dwPasswordLength, debugstr_an(lpUrlComponents->lpszExtraInfo, lpUrlComponents->dwExtraInfoLength));
lpszUrl, lpwszUrl); }
ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
UCW.lpszUrlPath, UCW.dwUrlPathLength,
lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
UCW.lpszScheme, UCW.dwSchemeLength,
lpszUrl, lpwszUrl);
ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
UCW.lpszExtraInfo, UCW.dwExtraInfoLength,
lpszUrl, lpwszUrl);
lpUrlComponents->nScheme=UCW.nScheme;
lpUrlComponents->nPort=UCW.nPort;
HeapFree(GetProcessHeap(), 0, lpwszUrl); HeapFree(GetProcessHeap(), 0, lpwszUrl);
HeapFree(GetProcessHeap(), 0, hostname);
TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl, HeapFree(GetProcessHeap(), 0, username);
debugstr_an(lpUrlComponents->lpszScheme,lpUrlComponents->dwSchemeLength), HeapFree(GetProcessHeap(), 0, password);
debugstr_an(lpUrlComponents->lpszHostName,lpUrlComponents->dwHostNameLength), HeapFree(GetProcessHeap(), 0, path);
debugstr_an(lpUrlComponents->lpszUrlPath,lpUrlComponents->dwUrlPathLength), HeapFree(GetProcessHeap(), 0, scheme);
debugstr_an(lpUrlComponents->lpszExtraInfo,lpUrlComponents->dwExtraInfoLength)); HeapFree(GetProcessHeap(), 0, extra);
return ret;
return TRUE;
} }
static const WCHAR url_schemes[][7] = static const WCHAR url_schemes[][7] =
@ -1264,10 +1401,10 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
LPCWSTR lpszcp = NULL; LPCWSTR lpszcp = NULL;
LPWSTR lpszUrl_decode = NULL; LPWSTR lpszUrl_decode = NULL;
DWORD dwUrlLength = dwUrlLength_orig; DWORD dwUrlLength = dwUrlLength_orig;
const WCHAR lpszSeparators[3]={';','?',0};
const WCHAR lpszSlash[2]={'/',0};
TRACE("(%s %u %x %p)\n", debugstr_w(lpszUrl), dwUrlLength, dwFlags, lpUC); TRACE("(%s %u %x %p)\n",
lpszUrl ? debugstr_wn(lpszUrl, dwUrlLength ? dwUrlLength : strlenW(lpszUrl)) : "(null)",
dwUrlLength, dwFlags, lpUC);
if (!lpszUrl_orig || !*lpszUrl_orig || !lpUC) if (!lpszUrl_orig || !*lpszUrl_orig || !lpUC)
{ {
@ -1278,16 +1415,33 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
if (dwFlags & ICU_DECODE) if (dwFlags & ICU_DECODE)
{ {
lpszUrl_decode=HeapAlloc( GetProcessHeap(), 0, dwUrlLength * sizeof (WCHAR) ); WCHAR *url_tmp;
if( InternetCanonicalizeUrlW(lpszUrl_orig, lpszUrl_decode, &dwUrlLength, dwFlags)) DWORD len = dwUrlLength + 1;
{
lpszUrl = lpszUrl_decode; if (!(url_tmp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
} {
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
memcpy(url_tmp, lpszUrl_orig, dwUrlLength * sizeof(WCHAR));
url_tmp[dwUrlLength] = 0;
if (!(lpszUrl_decode = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
{
HeapFree(GetProcessHeap(), 0, url_tmp);
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
if (InternetCanonicalizeUrlW(url_tmp, lpszUrl_decode, &len, ICU_DECODE | ICU_NO_ENCODE))
{
dwUrlLength = len;
lpszUrl = lpszUrl_decode;
}
HeapFree(GetProcessHeap(), 0, url_tmp);
} }
lpszap = lpszUrl; lpszap = lpszUrl;
/* Determine if the URI is absolute. */ /* Determine if the URI is absolute. */
while (*lpszap != '\0') while (lpszap - lpszUrl < dwUrlLength)
{ {
if (isalnumW(*lpszap)) if (isalnumW(*lpszap))
{ {
@ -1311,7 +1465,9 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
lpUC->nPort = INTERNET_INVALID_PORT_NUMBER; lpUC->nPort = INTERNET_INVALID_PORT_NUMBER;
/* Parse <params> */ /* Parse <params> */
lpszParam = strpbrkW(lpszap, lpszSeparators); if (!(lpszParam = memchrW(lpszap, ';', dwUrlLength - (lpszap - lpszUrl))))
lpszParam = memchrW(lpszap, '?', dwUrlLength - (lpszap - lpszUrl));
SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength, SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
lpszParam, lpszParam ? dwUrlLength-(lpszParam-lpszUrl) : 0); lpszParam, lpszParam ? dwUrlLength-(lpszParam-lpszUrl) : 0);
@ -1332,7 +1488,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
{ {
lpszcp += 2; lpszcp += 2;
lpszNetLoc = strpbrkW(lpszcp, lpszSlash); lpszNetLoc = memchrW(lpszcp, '/', dwUrlLength - (lpszcp - lpszUrl));
if (lpszParam) if (lpszParam)
{ {
if (lpszNetLoc) if (lpszNetLoc)
@ -1352,7 +1508,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
/* [<user>[<:password>]@]<host>[:<port>] */ /* [<user>[<:password>]@]<host>[:<port>] */
/* First find the user and password if they exist */ /* First find the user and password if they exist */
lpszHost = strchrW(lpszcp, '@'); lpszHost = memchrW(lpszcp, '@', dwUrlLength - (lpszcp - lpszUrl));
if (lpszHost == NULL || lpszHost > lpszNetLoc) if (lpszHost == NULL || lpszHost > lpszNetLoc)
{ {
/* username and password not specified. */ /* username and password not specified. */
@ -1461,7 +1617,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
* <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>] * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/ */
if (lpszcp != 0 && *lpszcp != '\0' && (!lpszParam || lpszcp < lpszParam)) if (lpszcp != 0 && lpszcp - lpszUrl < dwUrlLength && (!lpszParam || lpszcp < lpszParam))
{ {
INT len; INT len;
@ -1475,7 +1631,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
/* Leave the parameter list in lpszUrlPath. Strip off any trailing /* Leave the parameter list in lpszUrlPath. Strip off any trailing
* newlines if necessary. * newlines if necessary.
*/ */
LPWSTR lpsznewline = strchrW(lpszcp, '\n'); LPWSTR lpsznewline = memchrW(lpszcp, '\n', dwUrlLength - (lpszcp - lpszUrl));
if (lpsznewline != NULL) if (lpsznewline != NULL)
len = lpsznewline - lpszcp; len = lpsznewline - lpszcp;
else else
@ -1486,6 +1642,8 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
} }
else else
{ {
if (lpUC->lpszUrlPath && (lpUC->dwUrlPathLength > 0))
lpUC->lpszUrlPath[0] = 0;
lpUC->dwUrlPathLength = 0; lpUC->dwUrlPathLength = 0;
} }
@ -1586,7 +1744,7 @@ BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE; DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE;
TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl), lpszBuffer, TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl), lpszBuffer,
lpdwBufferLength, lpdwBufferLength ? *lpdwBufferLength : -1, dwFlags); lpdwBufferLength, dwFlags, lpdwBufferLength ? *lpdwBufferLength : -1);
if(dwFlags & ICU_DECODE) if(dwFlags & ICU_DECODE)
{ {
@ -1861,315 +2019,137 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
return FALSE; return FALSE;
} }
/*********************************************************************** DWORD INET_QueryOption(DWORD option, void *buffer, DWORD *size, BOOL unicode)
* INET_QueryOptionHelper (internal)
*/
static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
LPVOID lpBuffer, LPDWORD lpdwBufferLength)
{ {
LPWININETHANDLEHEADER lpwhh; switch(option) {
BOOL bSuccess = FALSE; case INTERNET_OPTION_REQUEST_FLAGS:
TRACE("INTERNET_OPTION_REQUEST_FLAGS\n");
TRACE("(%p, 0x%08x, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength); if (*size < sizeof(ULONG))
return ERROR_INSUFFICIENT_BUFFER;
lpwhh = WININET_GetObject( hInternet ); *(ULONG*)buffer = 4;
*size = sizeof(ULONG);
switch (dwOption) return ERROR_SUCCESS;
{
case INTERNET_OPTION_REQUEST_FLAGS:
{
ULONG flags = 4;
TRACE("INTERNET_OPTION_REQUEST_FLAGS: %d\n", flags);
if (*lpdwBufferLength < sizeof(ULONG))
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
memcpy(lpBuffer, &flags, sizeof(ULONG));
bSuccess = TRUE;
}
*lpdwBufferLength = sizeof(ULONG);
break;
}
case INTERNET_OPTION_USER_AGENT: case INTERNET_OPTION_HTTP_VERSION:
{ if (*size < sizeof(HTTP_VERSION_INFO))
DWORD required; return ERROR_INSUFFICIENT_BUFFER;
LPWININETAPPINFOW ai = (LPWININETAPPINFOW)lpwhh;
TRACE("INTERNET_OPTION_USER_AGENT\n"); /*
* Presently hardcoded to 1.1
*/
((HTTP_VERSION_INFO*)buffer)->dwMajorVersion = 1;
((HTTP_VERSION_INFO*)buffer)->dwMinorVersion = 1;
*size = sizeof(HTTP_VERSION_INFO);
if (lpwhh->htype != INTERNET_HANDLE_TYPE_INTERNET) return ERROR_SUCCESS;
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
}
if (bIsUnicode)
{
required = (strlenW(ai->lpszAgent) + 1) * sizeof(WCHAR);
if (*lpdwBufferLength < required)
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else if (lpBuffer)
{
strcpyW(lpBuffer, ai->lpszAgent);
bSuccess = TRUE;
}
}
else
{
required = WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, NULL, 0, NULL, NULL);
if (*lpdwBufferLength < required)
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else if (lpBuffer)
{
WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, lpBuffer, required, NULL, NULL);
bSuccess = TRUE;
}
}
*lpdwBufferLength = required;
break;
}
case INTERNET_OPTION_HTTP_VERSION:
{
if (*lpdwBufferLength < sizeof(HTTP_VERSION_INFO))
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
/*
* Presently hardcoded to 1.1
*/
((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
bSuccess = TRUE;
}
*lpdwBufferLength = sizeof(HTTP_VERSION_INFO);
break;
}
case INTERNET_OPTION_CONNECTED_STATE:
{
DWORD *pdwConnectedState = (DWORD *)lpBuffer;
FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
if (*lpdwBufferLength < sizeof(*pdwConnectedState)) case INTERNET_OPTION_CONNECTED_STATE:
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
else
{
*pdwConnectedState = INTERNET_STATE_CONNECTED;
bSuccess = TRUE;
}
*lpdwBufferLength = sizeof(*pdwConnectedState);
break;
}
case INTERNET_OPTION_PROXY:
{
LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW)lpwhh;
WININETAPPINFOW wai;
if (lpwai == NULL) if (*size < sizeof(ULONG))
{ return ERROR_INSUFFICIENT_BUFFER;
TRACE("Getting global proxy info\n");
memset(&wai, 0, sizeof(WININETAPPINFOW));
INTERNET_ConfigureProxy( &wai );
lpwai = &wai;
}
if (bIsUnicode) *(ULONG*)buffer = INTERNET_STATE_CONNECTED;
{ *size = sizeof(ULONG);
INTERNET_PROXY_INFOW *pPI = (INTERNET_PROXY_INFOW *)lpBuffer;
DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
if (lpwai->lpszProxy) return ERROR_SUCCESS;
proxyBytesRequired = (lstrlenW(lpwai->lpszProxy) + 1) *
sizeof(WCHAR);
if (lpwai->lpszProxyBypass)
proxyBypassBytesRequired =
(lstrlenW(lpwai->lpszProxyBypass) + 1) * sizeof(WCHAR);
if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOW) +
proxyBytesRequired + proxyBypassBytesRequired)
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
LPWSTR proxy = (LPWSTR)((LPBYTE)lpBuffer +
sizeof(INTERNET_PROXY_INFOW));
LPWSTR proxy_bypass = (LPWSTR)((LPBYTE)lpBuffer +
sizeof(INTERNET_PROXY_INFOW) +
proxyBytesRequired);
pPI->dwAccessType = lpwai->dwAccessType; case INTERNET_OPTION_PROXY: {
pPI->lpszProxy = NULL; WININETAPPINFOW ai;
pPI->lpszProxyBypass = NULL;
if (lpwai->lpszProxy)
{
lstrcpyW(proxy, lpwai->lpszProxy);
pPI->lpszProxy = proxy;
}
if (lpwai->lpszProxyBypass) TRACE("Getting global proxy info\n");
{ memset(&ai, 0, sizeof(WININETAPPINFOW));
lstrcpyW(proxy_bypass, lpwai->lpszProxyBypass); INTERNET_ConfigureProxy(&ai);
pPI->lpszProxyBypass = proxy_bypass;
}
bSuccess = TRUE;
}
*lpdwBufferLength = sizeof(INTERNET_PROXY_INFOW) +
proxyBytesRequired + proxyBypassBytesRequired;
}
else
{
INTERNET_PROXY_INFOA *pPI = (INTERNET_PROXY_INFOA *)lpBuffer;
DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
if (lpwai->lpszProxy) return APPINFO_QueryOption(&ai.hdr, INTERNET_OPTION_PROXY, buffer, size, unicode); /* FIXME */
proxyBytesRequired = WideCharToMultiByte(CP_ACP, 0, }
lpwai->lpszProxy, -1, NULL, 0, NULL, NULL);
if (lpwai->lpszProxyBypass)
proxyBypassBytesRequired = WideCharToMultiByte(CP_ACP, 0,
lpwai->lpszProxyBypass, -1, NULL, 0, NULL, NULL);
if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOA) +
proxyBytesRequired + proxyBypassBytesRequired)
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
LPSTR proxy = (LPSTR)((LPBYTE)lpBuffer +
sizeof(INTERNET_PROXY_INFOA));
LPSTR proxy_bypass = (LPSTR)((LPBYTE)lpBuffer +
sizeof(INTERNET_PROXY_INFOA) +
proxyBytesRequired);
pPI->dwAccessType = lpwai->dwAccessType; case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
pPI->lpszProxy = NULL; TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER\n");
pPI->lpszProxyBypass = NULL;
if (lpwai->lpszProxy)
{
WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxy, -1,
proxy, proxyBytesRequired, NULL, NULL);
pPI->lpszProxy = proxy;
}
if (lpwai->lpszProxyBypass) if (*size < sizeof(ULONG))
{ return ERROR_INSUFFICIENT_BUFFER;
WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxyBypass,
-1, proxy_bypass, proxyBypassBytesRequired,
NULL, NULL);
pPI->lpszProxyBypass = proxy_bypass;
}
bSuccess = TRUE;
}
*lpdwBufferLength = sizeof(INTERNET_PROXY_INFOA) +
proxyBytesRequired + proxyBypassBytesRequired;
}
break;
}
case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
{
ULONG conn = 2;
TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", conn);
if (*lpdwBufferLength < sizeof(ULONG))
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
memcpy(lpBuffer, &conn, sizeof(ULONG));
bSuccess = TRUE;
}
*lpdwBufferLength = sizeof(ULONG);
break;
}
case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
{
ULONG conn = 4;
TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER: %d\n", conn);
if (*lpdwBufferLength < sizeof(ULONG))
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
memcpy(lpBuffer, &conn, sizeof(ULONG));
bSuccess = TRUE;
}
*lpdwBufferLength = sizeof(ULONG);
break;
}
case INTERNET_OPTION_SECURITY_FLAGS:
FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
bSuccess = TRUE;
break;
case INTERNET_OPTION_VERSION: *(ULONG*)buffer = 2;
{ *size = sizeof(ULONG);
TRACE("INTERNET_OPTION_VERSION\n");
if (*lpdwBufferLength < sizeof(INTERNET_VERSION_INFO))
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
static const INTERNET_VERSION_INFO info = { 1, 2 };
memcpy(lpBuffer, &info, sizeof(info));
*lpdwBufferLength = sizeof(info);
bSuccess = TRUE;
}
break;
}
case INTERNET_OPTION_PER_CONNECTION_OPTION:
FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
if (*lpdwBufferLength < sizeof(INTERNET_PER_CONN_OPTION_LISTW))
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
INTERNET_PER_CONN_OPTION_LISTW *con = lpBuffer;
int x;
bSuccess = TRUE;
for (x = 0; x < con->dwOptionCount; ++x)
{
INTERNET_PER_CONN_OPTIONW *option = con->pOptions + x;
switch (option->dwOption)
{
case INTERNET_PER_CONN_FLAGS:
option->Value.dwValue = PROXY_TYPE_DIRECT;
break;
case INTERNET_PER_CONN_PROXY_SERVER: return ERROR_SUCCESS;
case INTERNET_PER_CONN_PROXY_BYPASS:
case INTERNET_PER_CONN_AUTOCONFIG_URL:
case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS:
case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS:
case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME:
case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL:
FIXME("Unhandled dwOption %d\n", option->dwOption);
option->Value.dwValue = 0;
bSuccess = FALSE;
break;
default: case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
FIXME("Unknown dwOption %d\n", option->dwOption); TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER\n");
bSuccess = FALSE;
break;
}
}
if (!bSuccess)
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case 66:
FIXME("66\n");
bSuccess = TRUE;
break;
default: {
if(lpwhh) {
DWORD res;
res = lpwhh->vtbl->QueryOption(lpwhh, dwOption, lpBuffer, lpdwBufferLength, bIsUnicode); if (*size < sizeof(ULONG))
if(res == ERROR_SUCCESS) return ERROR_INSUFFICIENT_BUFFER;
bSuccess = TRUE;
else *(ULONG*)size = 4;
SetLastError(res); *size = sizeof(ULONG);
}else {
FIXME("Stub! %d\n", dwOption); return ERROR_SUCCESS;
case INTERNET_OPTION_SECURITY_FLAGS:
FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
return ERROR_SUCCESS;
case INTERNET_OPTION_VERSION: {
static const INTERNET_VERSION_INFO info = { 1, 2 };
TRACE("INTERNET_OPTION_VERSION\n");
if (*size < sizeof(INTERNET_VERSION_INFO))
return ERROR_INSUFFICIENT_BUFFER;
memcpy(buffer, &info, sizeof(info));
*size = sizeof(info);
return ERROR_SUCCESS;
}
case INTERNET_OPTION_PER_CONNECTION_OPTION: {
INTERNET_PER_CONN_OPTION_LISTW *con = buffer;
DWORD res = ERROR_SUCCESS, i;
FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
if (*size < sizeof(INTERNET_PER_CONN_OPTION_LISTW))
return ERROR_INSUFFICIENT_BUFFER;
for (i = 0; i < con->dwOptionCount; i++) {
INTERNET_PER_CONN_OPTIONW *option = con->pOptions + i;
switch (option->dwOption) {
case INTERNET_PER_CONN_FLAGS:
option->Value.dwValue = PROXY_TYPE_DIRECT;
break;
case INTERNET_PER_CONN_PROXY_SERVER:
case INTERNET_PER_CONN_PROXY_BYPASS:
case INTERNET_PER_CONN_AUTOCONFIG_URL:
case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS:
case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS:
case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME:
case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL:
FIXME("Unhandled dwOption %d\n", option->dwOption);
option->Value.dwValue = 0;
res = ERROR_INVALID_PARAMETER;
break;
default:
FIXME("Unknown dwOption %d\n", option->dwOption);
res = ERROR_INVALID_PARAMETER;
break; break;
} }
} }
}
if (lpwhh)
WININET_Release( lpwhh );
return bSuccess; return res;
}
}
FIXME("Stub for %d\n", option);
return ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
} }
/*********************************************************************** /***********************************************************************
@ -2185,7 +2165,24 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d
BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption, BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
LPVOID lpBuffer, LPDWORD lpdwBufferLength) LPVOID lpBuffer, LPDWORD lpdwBufferLength)
{ {
return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength); LPWININETHANDLEHEADER hdr;
DWORD res = ERROR_INVALID_HANDLE;
TRACE("%p %d %p %p\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
if(hInternet) {
hdr = WININET_GetObject(hInternet);
if (hdr) {
res = hdr->vtbl->QueryOption(hdr, dwOption, lpBuffer, lpdwBufferLength, TRUE);
WININET_Release(hdr);
}
}else {
res = INET_QueryOption(dwOption, lpBuffer, lpdwBufferLength, TRUE);
}
if(res != ERROR_SUCCESS)
SetLastError(res);
return res == ERROR_SUCCESS;
} }
/*********************************************************************** /***********************************************************************
@ -2201,7 +2198,24 @@ BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption, BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
LPVOID lpBuffer, LPDWORD lpdwBufferLength) LPVOID lpBuffer, LPDWORD lpdwBufferLength)
{ {
return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength); LPWININETHANDLEHEADER hdr;
DWORD res = ERROR_INVALID_HANDLE;
TRACE("%p %d %p %p\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
if(hInternet) {
hdr = WININET_GetObject(hInternet);
if (hdr) {
res = hdr->vtbl->QueryOption(hdr, dwOption, lpBuffer, lpdwBufferLength, FALSE);
WININET_Release(hdr);
}
}else {
res = INET_QueryOption(dwOption, lpBuffer, lpdwBufferLength, FALSE);
}
if(res != ERROR_SUCCESS)
SetLastError(res);
return res == ERROR_SUCCESS;
} }
@ -2254,44 +2268,44 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
break; break;
case INTERNET_OPTION_ERROR_MASK: case INTERNET_OPTION_ERROR_MASK:
{ {
unsigned long flags=*(unsigned long*)lpBuffer; ULONG flags = *(ULONG *)lpBuffer;
FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags); FIXME("Option INTERNET_OPTION_ERROR_MASK(%d): STUB\n", flags);
} }
break; break;
case INTERNET_OPTION_CODEPAGE: case INTERNET_OPTION_CODEPAGE:
{ {
unsigned long codepage=*(unsigned long*)lpBuffer; ULONG codepage = *(ULONG *)lpBuffer;
FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage); FIXME("Option INTERNET_OPTION_CODEPAGE (%d): STUB\n", codepage);
} }
break; break;
case INTERNET_OPTION_REQUEST_PRIORITY: case INTERNET_OPTION_REQUEST_PRIORITY:
{ {
unsigned long priority=*(unsigned long*)lpBuffer; ULONG priority = *(ULONG *)lpBuffer;
FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority); FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%d): STUB\n", priority);
} }
break; break;
case INTERNET_OPTION_CONNECT_TIMEOUT: case INTERNET_OPTION_CONNECT_TIMEOUT:
{ {
unsigned long connecttimeout=*(unsigned long*)lpBuffer; ULONG connecttimeout = *(ULONG *)lpBuffer;
FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%ld): STUB\n",connecttimeout); FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%d): STUB\n", connecttimeout);
} }
break; break;
case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT: case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT:
{ {
unsigned long receivetimeout=*(unsigned long*)lpBuffer; ULONG receivetimeout = *(ULONG *)lpBuffer;
FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%ld): STUB\n",receivetimeout); FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%d): STUB\n", receivetimeout);
} }
break; break;
case INTERNET_OPTION_MAX_CONNS_PER_SERVER: case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
{ {
unsigned long conns=*(unsigned long*)lpBuffer; ULONG conns = *(ULONG *)lpBuffer;
FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%ld): STUB\n",conns); FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%d): STUB\n", conns);
} }
break; break;
case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER: case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
{ {
unsigned long conns=*(unsigned long*)lpBuffer; ULONG conns = *(ULONG *)lpBuffer;
FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%ld): STUB\n",conns); FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%d): STUB\n", conns);
} }
break; break;
case INTERNET_OPTION_RESET_URLCACHE_SESSION: case INTERNET_OPTION_RESET_URLCACHE_SESSION:
@ -2308,17 +2322,26 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
break; break;
case INTERNET_OPTION_SEND_TIMEOUT: case INTERNET_OPTION_SEND_TIMEOUT:
case INTERNET_OPTION_RECEIVE_TIMEOUT: case INTERNET_OPTION_RECEIVE_TIMEOUT:
FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT\n"); {
ULONG timeout = *(ULONG *)lpBuffer;
FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT %d\n", timeout);
break; break;
}
case INTERNET_OPTION_CONNECT_RETRIES: case INTERNET_OPTION_CONNECT_RETRIES:
FIXME("Option INTERNET_OPTION_CONNECT_RETRIES: STUB\n"); {
ULONG retries = *(ULONG *)lpBuffer;
FIXME("INTERNET_OPTION_CONNECT_RETRIES %d\n", retries);
break; break;
}
case INTERNET_OPTION_CONTEXT_VALUE: case INTERNET_OPTION_CONTEXT_VALUE:
FIXME("Option INTERNET_OPTION_CONTEXT_VALUE; STUB\n"); FIXME("Option INTERNET_OPTION_CONTEXT_VALUE; STUB\n");
break; break;
case INTERNET_OPTION_SECURITY_FLAGS: case INTERNET_OPTION_SECURITY_FLAGS:
FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n"); FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n");
break; break;
case INTERNET_OPTION_DISABLE_AUTODIAL:
FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n");
break;
case 86: case 86:
FIXME("86\n"); FIXME("86\n");
break; break;
@ -2638,7 +2661,7 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
URL_COMPONENTSW components; URL_COMPONENTSW components;
ZeroMemory(&components,sizeof(URL_COMPONENTSW)); ZeroMemory(&components,sizeof(URL_COMPONENTSW));
components.lpszHostName = (LPWSTR)&hostW; components.lpszHostName = (LPWSTR)hostW;
components.dwHostNameLength = 1024; components.dwHostNameLength = 1024;
if (!InternetCrackUrlW(lpszUrl,0,0,&components)) if (!InternetCrackUrlW(lpszUrl,0,0,&components))
@ -3353,7 +3376,7 @@ static LPCWSTR INTERNET_GetSchemeString(INTERNET_SCHEME scheme)
index = scheme - INTERNET_SCHEME_FIRST; index = scheme - INTERNET_SCHEME_FIRST;
if (index >= sizeof(url_schemes)/sizeof(url_schemes[0])) if (index >= sizeof(url_schemes)/sizeof(url_schemes[0]))
return NULL; return NULL;
return (LPCWSTR)&url_schemes[index]; return (LPCWSTR)url_schemes[index];
} }
/* we can calculate using ansi strings because we're just /* we can calculate using ansi strings because we're just

View file

@ -41,18 +41,6 @@
# include <sys/types.h> # include <sys/types.h>
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
#ifdef HAVE_OPENSSL_SSL_H
#define DSA __ssl_DSA /* avoid conflict with commctrl.h */
#undef FAR
/* avoid conflict with wincrypt.h */
#undef PKCS7_SIGNER_INFO
#undef X509_NAME
#undef X509_CERT_PAIR
# include <openssl/ssl.h>
#undef FAR
#define FAR do_not_use_this_in_wine
#undef DSA
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -72,12 +60,10 @@ typedef struct
{ {
BOOL useSSL; BOOL useSSL;
int socketFD; int socketFD;
#ifdef HAVE_OPENSSL_SSL_H void *ssl_s;
SSL *ssl_s;
char *peek_msg; char *peek_msg;
char *peek_msg_mem; char *peek_msg_mem;
size_t peek_len; size_t peek_len;
#endif
} WININET_NETCONNECTION; } WININET_NETCONNECTION;
static inline LPWSTR WININET_strdupW( LPCWSTR str ) static inline LPWSTR WININET_strdupW( LPCWSTR str )
@ -364,6 +350,8 @@ LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
BOOL WININET_Release( LPWININETHANDLEHEADER info ); BOOL WININET_Release( LPWININETHANDLEHEADER info );
BOOL WININET_FreeHandle( HINTERNET hinternet ); BOOL WININET_FreeHandle( HINTERNET hinternet );
DWORD INET_QueryOption(DWORD,void*,DWORD*,BOOL);
time_t ConvertTimeString(LPCWSTR asctime); time_t ConvertTimeString(LPCWSTR asctime);
HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,

View file

@ -23,6 +23,7 @@
#include "config.h" #include "config.h"
#include "wine/port.h" #include "wine/port.h"
#include <sys/types.h>
#ifdef HAVE_POLL_H #ifdef HAVE_POLL_H
#include <poll.h> #include <poll.h>
#endif #endif
@ -42,6 +43,22 @@
#ifdef HAVE_SYS_IOCTL_H #ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h> # include <sys/ioctl.h>
#endif #endif
#include <time.h>
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_OPENSSL_SSL_H
# include <openssl/ssl.h>
#undef FAR
#undef DSA
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View file

@ -57,6 +57,7 @@
#include "wininet_No.rc" #include "wininet_No.rc"
#include "wininet_Pl.rc" #include "wininet_Pl.rc"
#include "wininet_Pt.rc" #include "wininet_Pt.rc"
#include "wininet_Ro.rc"
#include "wininet_Ru.rc" #include "wininet_Ru.rc"
#include "wininet_Si.rc" #include "wininet_Si.rc"
#include "wininet_Sv.rc" #include "wininet_Sv.rc"

View file

@ -2339,7 +2339,7 @@ static BOOL WINAPI CommitUrlCacheEntryInternal(
/* skip container path prefix */ /* skip container path prefix */
lpszLocalFileName += lstrlenW(pContainer->path); lpszLocalFileName += lstrlenW(pContainer->path);
WideCharToMultiByte(CP_ACP, 0, lpszLocalFileName, -1, achFile, -1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, lpszLocalFileName, -1, achFile, MAX_PATH, NULL, NULL);
pchLocalFileName = achFile; pchLocalFileName = achFile;
for (cDirectory = 0; cDirectory < pHeader->DirectoryCount; cDirectory++) for (cDirectory = 0; cDirectory < pHeader->DirectoryCount; cDirectory++)

View file

@ -40,6 +40,16 @@
WINE_DEFAULT_DEBUG_CHANNEL(wininet); WINE_DEFAULT_DEBUG_CHANNEL(wininet);
/* critical section to protect non-reentrant gethostbyname() */
static CRITICAL_SECTION cs_gethostbyname;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &cs_gethostbyname,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": cs_gethostbyname") }
};
static CRITICAL_SECTION cs_gethostbyname = { &critsect_debug, -1, 0, 0, 0, 0 };
#define TIME_STRING_LEN 30 #define TIME_STRING_LEN 30
time_t ConvertTimeString(LPCWSTR asctime) time_t ConvertTimeString(LPCWSTR asctime)
@ -151,12 +161,15 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
name = HeapAlloc(GetProcessHeap(), 0, sz+1); name = HeapAlloc(GetProcessHeap(), 0, sz+1);
WideCharToMultiByte( CP_UNIXCP, 0, lpszServerName, len, name, sz, NULL, NULL ); WideCharToMultiByte( CP_UNIXCP, 0, lpszServerName, len, name, sz, NULL, NULL );
name[sz] = 0; name[sz] = 0;
EnterCriticalSection( &cs_gethostbyname );
phe = gethostbyname(name); phe = gethostbyname(name);
HeapFree( GetProcessHeap(), 0, name ); HeapFree( GetProcessHeap(), 0, name );
if (NULL == phe) if (NULL == phe)
{ {
TRACE("Failed to get hostname: (%s)\n", debugstr_w(lpszServerName) ); TRACE("Failed to get hostname: (%s)\n", debugstr_w(lpszServerName) );
LeaveCriticalSection( &cs_gethostbyname );
return FALSE; return FALSE;
} }
@ -165,6 +178,7 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
psa->sin_family = phe->h_addrtype; psa->sin_family = phe->h_addrtype;
psa->sin_port = htons(nServerPort); psa->sin_port = htons(nServerPort);
LeaveCriticalSection( &cs_gethostbyname );
return TRUE; return TRUE;
} }

View file

@ -0,0 +1,49 @@
/*
* Copyright 2003 Mike McCormack for CodeWeavers
* Copyright 2008 Michael Stefaniuc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
#pragma code_page(65001)
IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Introducere parolă de rețea"
FONT 8, "MS Shell Dlg"
{
LTEXT "Introduceți numele de utilizator și parola:", -1, 40, 6, 150, 15
LTEXT "Proxy", -1, 40, 26, 50, 10
LTEXT "Realm", -1, 40, 46, 50, 10
LTEXT "Utilizator", -1, 40, 66, 50, 10
LTEXT "Parolă", -1, 40, 86, 50, 10
LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0
LTEXT "" IDC_REALM, 80, 46, 150, 14, 0
EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP
EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD
CHECKBOX "&Salvează această parolă (nesigur)", IDC_SAVEPASSWORD,
80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON
PUSHBUTTON "Renunță", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP
}
STRINGTABLE DISCARDABLE
{
IDS_LANCONNECTION "Conexiune LAN"
}
#pragma code_page(default)

View file

@ -9,28 +9,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(wininet); WINE_DEFAULT_DEBUG_CHANNEL(wininet);
static const WCHAR g_szHttp1_0[] = {'H','T','T','P','/','1','.','0',0}; static const WCHAR g_szHttp1_0[] = {'H','T','T','P','/','1','.','0',0};
@@ -1617,8 +1619,9 @@
if(req->lpszCacheFile) {
BOOL res;
+ DWORD dwBytesWritten;
- res = WriteFile(req->hCacheFile, buffer, bytes_read, NULL, NULL);
+ res = WriteFile(req->hCacheFile, buffer, bytes_read, &dwBytesWritten, NULL);
if(!res)
WARN("WriteFile failed: %u\n", GetLastError());
}
@@ -1686,7 +1689,9 @@
if (req->lpszCacheFile)
{
- if (!WriteFile(req->hCacheFile, p, bytes_read, NULL, NULL))
+ DWORD dwBytesWritten;
+
+ if (!WriteFile(req->hCacheFile, p, bytes_read, &dwBytesWritten, NULL))
WARN("WriteFile failed: %u\n", GetLastError());
}
p += bytes_read;
--- D:/Wine-CVS/wine/dlls/wininet/internet.c Wed May 28 14:33:28 2008 --- D:/Wine-CVS/wine/dlls/wininet/internet.c Wed May 28 14:33:28 2008
+++ D:/ReactOS-Trunk/reactos/dll/win32/wininet/internet.c Fri May 30 18:04:29 2008 +++ D:/ReactOS-Trunk/reactos/dll/win32/wininet/internet.c Fri May 30 18:04:29 2008
@@ -3101,19 +3101,22 @@ @@ -3101,19 +3101,22 @@