winhttp(4/13): Support getting the default proxy settings from the http_proxy environment variable

Juan Lang juan.lang at gmail.com
Tue Jul 14 15:22:21 CDT 2009


--Juan
-------------- next part --------------
From a70fb2863ac15af41f67af507ca548556d041d2a Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Tue, 14 Jul 2009 13:01:26 -0700
Subject: [PATCH 04/13] Support getting the default proxy settings from the http_proxy environment variable

---
 dlls/winhttp/session.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 17a0a5f..8a9a039 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -21,6 +21,7 @@
 #include "wine/debug.h"
 
 #include <stdarg.h>
+#include <stdlib.h>
 
 #include "windef.h"
 #include "winbase.h"
@@ -686,6 +687,7 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
     LONG l;
     HKEY key;
     BOOL direct = TRUE;
+    char *envproxy;
 
     TRACE("%p\n", info);
 
@@ -749,6 +751,9 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
                             direct = FALSE;
                             info->dwAccessType =
                                 WINHTTP_ACCESS_TYPE_NAMED_PROXY;
+                            TRACE("http proxy (from registry) = %s, bypass = %s\n",
+                                debugstr_w(info->lpszProxy),
+                                debugstr_w(info->lpszProxyBypass));
                         }
                     }
                 }
@@ -757,6 +762,23 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
         }
         RegCloseKey( key );
     }
+    else if ((envproxy = getenv( "http_proxy" )))
+    {
+        WCHAR *envproxyW;
+        int len;
+
+        len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 );
+        if ((envproxyW = GlobalAlloc( 0, len * sizeof(WCHAR))))
+        {
+            MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len );
+            direct = FALSE;
+            info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
+            info->lpszProxy = envproxyW;
+            info->lpszProxyBypass = NULL;
+            TRACE("http proxy (from environment) = %s\n",
+                debugstr_w(info->lpszProxy));
+        }
+    }
     if (direct)
     {
         info->dwAccessType    = WINHTTP_ACCESS_TYPE_NO_PROXY;
-- 
1.6.3.2


More information about the wine-patches mailing list