Commit 94c02fef authored by Dominik Strasser's avatar Dominik Strasser Committed by Alexandre Julliard

Partially implement proxy support.

parent 041a8de2
...@@ -4,7 +4,7 @@ TOPOBJDIR = ../.. ...@@ -4,7 +4,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = wininet.dll MODULE = wininet.dll
IMPORTS = shlwapi user32 kernel32 IMPORTS = shlwapi user32 advapi32 kernel32
EXTRALIBS = $(LIBUNICODE) EXTRALIBS = $(LIBUNICODE)
LDDLLFLAGS = @LDDLLFLAGS@ LDDLLFLAGS = @LDDLLFLAGS@
......
...@@ -382,6 +382,40 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession, ...@@ -382,6 +382,40 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
InternetCrackUrlA(lpszReferrer, 0, 0, &UrlComponents); InternetCrackUrlA(lpszReferrer, 0, 0, &UrlComponents);
if (strlen(UrlComponents.lpszHostName)) if (strlen(UrlComponents.lpszHostName))
lpwhr->lpszHostName = HTTP_strdup(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 { } else {
lpwhr->lpszHostName = HTTP_strdup(lpwhs->lpszServerName); lpwhr->lpszHostName = HTTP_strdup(lpwhs->lpszServerName);
} }
...@@ -910,7 +944,8 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, ...@@ -910,7 +944,8 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
if (NULL == lpwhr->lpszPath) if (NULL == lpwhr->lpszPath)
lpwhr->lpszPath = HTTP_strdup("/"); 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); char *fixurl = HeapAlloc(GetProcessHeap(), 0, strlen(lpwhr->lpszPath) + 2);
*fixurl = '/'; *fixurl = '/';
...@@ -1100,7 +1135,7 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName, ...@@ -1100,7 +1135,7 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
hIC = (LPWININETAPPINFOA) hInternet; hIC = (LPWININETAPPINFOA) hInternet;
hIC->hdr.dwContext = dwContext; hIC->hdr.dwContext = dwContext;
lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONA)); lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONA));
if (NULL == lpwhs) if (NULL == lpwhs)
{ {
...@@ -1119,6 +1154,12 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName, ...@@ -1119,6 +1154,12 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
lpwhs->hdr.lpwhparent = (LPWININETHANDLEHEADER)hInternet; lpwhs->hdr.lpwhparent = (LPWININETHANDLEHEADER)hInternet;
lpwhs->hdr.dwFlags = dwFlags; lpwhs->hdr.dwFlags = dwFlags;
lpwhs->hdr.dwContext = dwContext; 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) if (NULL != lpszServerName)
lpwhs->lpszServerName = HTTP_strdup(lpszServerName); lpwhs->lpszServerName = HTTP_strdup(lpszServerName);
if (NULL != lpszUserName) if (NULL != lpszUserName)
......
...@@ -224,7 +224,31 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, ...@@ -224,7 +224,31 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
if ((lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,strlen(lpszAgent)+1))) if ((lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,strlen(lpszAgent)+1)))
strcpy( lpwai->lpszAgent, lpszAgent ); 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 ))) if ((lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0, strlen(lpszProxy)+1 )))
strcpy( lpwai->lpszProxy, lpszProxy ); strcpy( lpwai->lpszProxy, lpszProxy );
...@@ -641,7 +665,7 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet) ...@@ -641,7 +665,7 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
/*********************************************************************** /***********************************************************************
* ConvertUrlComponentValue (Internal) * ConvertUrlComponentValue (Internal)
* *
* Helper function for InternetCrackUrlA * Helper function for InternetCrackUrlW
* *
*/ */
void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen, void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment