Partially implement proxy support.
This commit is contained in:
parent
041a8de270
commit
94c02fef1a
|
@ -4,7 +4,7 @@ TOPOBJDIR = ../..
|
|||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
MODULE = wininet.dll
|
||||
IMPORTS = shlwapi user32 kernel32
|
||||
IMPORTS = shlwapi user32 advapi32 kernel32
|
||||
EXTRALIBS = $(LIBUNICODE)
|
||||
|
||||
LDDLLFLAGS = @LDDLLFLAGS@
|
||||
|
|
|
@ -382,6 +382,40 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
|
|||
InternetCrackUrlA(lpszReferrer, 0, 0, &UrlComponents);
|
||||
if (strlen(UrlComponents.lpszHostName))
|
||||
lpwhr->lpszHostName = HTTP_strdup(UrlComponents.lpszHostName);
|
||||
} else if (NULL != hIC->lpszProxy && hIC->lpszProxy[0] != 0) {
|
||||
char buf[MAXHOSTNAME];
|
||||
char proxy[MAXHOSTNAME + 13]; /* 13 == "http://" + sizeof(port#) + ":/\0" */
|
||||
URL_COMPONENTSA UrlComponents;
|
||||
|
||||
UrlComponents.lpszExtraInfo = NULL;
|
||||
UrlComponents.lpszPassword = NULL;
|
||||
UrlComponents.lpszScheme = NULL;
|
||||
UrlComponents.lpszUrlPath = NULL;
|
||||
UrlComponents.lpszUserName = NULL;
|
||||
UrlComponents.lpszHostName = buf;
|
||||
UrlComponents.dwHostNameLength = MAXHOSTNAME;
|
||||
|
||||
sprintf(proxy, "http://%s/", hIC->lpszProxy);
|
||||
InternetCrackUrlA(proxy, 0, 0, &UrlComponents);
|
||||
if (strlen(UrlComponents.lpszHostName)) {
|
||||
/* for constant 13 see above */
|
||||
char* url = HeapAlloc(GetProcessHeap(), 0, strlen(lpwhr->lpszHostName) + strlen(lpwhr->lpszPath) + 13);
|
||||
|
||||
if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER)
|
||||
UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
|
||||
if(lpwhr->lpszHostName != 0) {
|
||||
HeapFree(GetProcessHeap(), 0, lpwhr->lpszHostName);
|
||||
lpwhr->lpszHostName = 0;
|
||||
}
|
||||
sprintf(url, "http://%s:%d/%s", lpwhs->lpszServerName, lpwhs->nServerPort, lpwhr->lpszPath);
|
||||
if(lpwhr->lpszPath)
|
||||
HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);
|
||||
lpwhr->lpszPath = url;
|
||||
/* FIXME: Do I have to free lpwhs->lpszServerName here ? */
|
||||
lpwhs->lpszServerName = HTTP_strdup(UrlComponents.lpszHostName);
|
||||
lpwhs->nServerPort = UrlComponents.nPort;
|
||||
}
|
||||
} else {
|
||||
lpwhr->lpszHostName = HTTP_strdup(lpwhs->lpszServerName);
|
||||
}
|
||||
|
@ -910,7 +944,8 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
|
|||
if (NULL == lpwhr->lpszPath)
|
||||
lpwhr->lpszPath = HTTP_strdup("/");
|
||||
|
||||
if(lpwhr->lpszPath[0] != '/') /* not an absolute path ?? --> fix it !! */
|
||||
if(strncmp(lpwhr->lpszPath, "http://", sizeof("http://") -1) != 0
|
||||
&& lpwhr->lpszPath[0] != '/') /* not an absolute path ?? --> fix it !! */
|
||||
{
|
||||
char *fixurl = HeapAlloc(GetProcessHeap(), 0, strlen(lpwhr->lpszPath) + 2);
|
||||
*fixurl = '/';
|
||||
|
@ -1100,7 +1135,7 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
|
|||
|
||||
hIC = (LPWININETAPPINFOA) hInternet;
|
||||
hIC->hdr.dwContext = dwContext;
|
||||
|
||||
|
||||
lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONA));
|
||||
if (NULL == lpwhs)
|
||||
{
|
||||
|
@ -1119,6 +1154,12 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
|
|||
lpwhs->hdr.lpwhparent = (LPWININETHANDLEHEADER)hInternet;
|
||||
lpwhs->hdr.dwFlags = dwFlags;
|
||||
lpwhs->hdr.dwContext = dwContext;
|
||||
if(hIC->lpszProxy && hIC->dwAccessType == INTERNET_OPEN_TYPE_PROXY) {
|
||||
if(strchr(hIC->lpszProxy, ' '))
|
||||
FIXME("Several proxies not implemented.\n");
|
||||
if(hIC->lpszProxyBypass)
|
||||
FIXME("Proxy bypass is ignored.\n");
|
||||
}
|
||||
if (NULL != lpszServerName)
|
||||
lpwhs->lpszServerName = HTTP_strdup(lpszServerName);
|
||||
if (NULL != lpszUserName)
|
||||
|
|
|
@ -224,7 +224,31 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
|
|||
if ((lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,strlen(lpszAgent)+1)))
|
||||
strcpy( lpwai->lpszAgent, lpszAgent );
|
||||
}
|
||||
if (NULL != lpszProxy)
|
||||
if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG)
|
||||
{
|
||||
HKEY key;
|
||||
if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", &key))
|
||||
{
|
||||
DWORD keytype, len, enabled;
|
||||
RegQueryValueExA(key, "ProxyEnable", NULL, NULL, (BYTE*)&enabled, NULL);
|
||||
if(enabled)
|
||||
{
|
||||
if(!RegQueryValueExA(key, "ProxyServer", NULL, &keytype, NULL, &len) && len && keytype == REG_SZ)
|
||||
{
|
||||
lpwai->lpszProxy=HeapAlloc( GetProcessHeap(), 0, len+1 );
|
||||
RegQueryValueExA(key, "ProxyServer", NULL, &keytype, (BYTE*)lpwai->lpszProxy, &len);
|
||||
TRACE("Proxy = %s\n", lpwai->lpszProxy);
|
||||
dwAccessType = INTERNET_OPEN_TYPE_PROXY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Proxy is not enabled.\n");
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
}
|
||||
else if (NULL != lpszProxy)
|
||||
{
|
||||
if ((lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0, strlen(lpszProxy)+1 )))
|
||||
strcpy( lpwai->lpszProxy, lpszProxy );
|
||||
|
@ -641,7 +665,7 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
|
|||
/***********************************************************************
|
||||
* ConvertUrlComponentValue (Internal)
|
||||
*
|
||||
* Helper function for InternetCrackUrlA
|
||||
* Helper function for InternetCrackUrlW
|
||||
*
|
||||
*/
|
||||
void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
|
||||
|
|
Loading…
Reference in New Issue