resend: Implement proxy in wininet (partially)
Dominik Strasser
dominik.strasser at epost.de
Sun Feb 2 14:40:45 CST 2003
Is there a reason wyh this patch wasn't applied ?
Anyway, here it is again:
Changelog:
implement proxies in wininet to an extent that IE6 setup works
behind a firewall
Regards
Dominik
-------------- next part --------------
Index: dlls/wininet/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/wininet/Makefile.in,v
retrieving revision 1.19
diff -u -3 -p -r1.19 Makefile.in
--- dlls/wininet/Makefile.in 12 Nov 2002 02:13:04 -0000 1.19
+++ dlls/wininet/Makefile.in 15 Jan 2003 22:07:03 -0000
@@ -4,7 +4,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = wininet.dll
-IMPORTS = shlwapi user32 kernel32
+IMPORTS = shlwapi advapi32 user32 kernel32
EXTRALIBS = $(LIBUNICODE)
LDDLLFLAGS = @LDDLLFLAGS@
Index: dlls/wininet/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/http.c,v
retrieving revision 1.32
diff -u -3 -p -r1.32 http.c
--- dlls/wininet/http.c 6 Dec 2002 23:20:31 -0000 1.32
+++ dlls/wininet/http.c 15 Jan 2003 22:07:04 -0000
@@ -380,6 +380,39 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(H
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 + 6 + 7];
+ 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)) {
+ char url[10000]; // FIXME: use a reasonable length
+
+ 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 = HTTP_strdup(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);
}
@@ -908,7 +941,8 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTER
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 = '/';
@@ -1098,7 +1132,7 @@ HINTERNET HTTP_Connect(HINTERNET hIntern
hIC = (LPWININETAPPINFOA) hInternet;
hIC->hdr.dwContext = dwContext;
-
+
lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONA));
if (NULL == lpwhs)
{
@@ -1117,6 +1151,12 @@ HINTERNET HTTP_Connect(HINTERNET hIntern
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)
Index: dlls/wininet/internet.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/internet.c,v
retrieving revision 1.49
diff -u -3 -p -r1.49 internet.c
--- dlls/wininet/internet.c 2 Jan 2003 23:08:22 -0000 1.49
+++ dlls/wininet/internet.c 15 Jan 2003 22:07:05 -0000
@@ -224,7 +224,31 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lp
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(HINTERNE
/***********************************************************************
* ConvertUrlComponentValue (Internal)
*
- * Helper function for InternetCrackUrlA
+ * Helper function for InternetCrackUrlW
*
*/
void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
More information about the wine-patches
mailing list