1--- curl/winbuild/MakefileBuild.vc.orig	2017-10-23 17:15:22.969492548 +0200
2+++ curl/winbuild/MakefileBuild.vc	2017-10-23 17:16:38.491490679 +0200
3@@ -72,7 +72,7 @@
4
5 CFLAGS_LIBCURL_STATIC  = /DCURL_STATICLIB
6
7-WIN_LIBS    = ws2_32.lib wldap32.lib advapi32.lib crypt32.lib
8+WIN_LIBS    = ws2_32.lib wldap32.lib advapi32.lib crypt32.lib winhttp.lib
9
10 BASE_NAME              = libcurl
11 BASE_NAME_DEBUG        = $(BASE_NAME)_debug
12--- curl-7.26.0/lib/url.c
13+++ misc/build/curl-7.26.0/lib/url.c
14@@ -78,6 +78,10 @@
15 bool curl_win32_idn_to_ascii(const char *in, char **out);
16 #endif  /* USE_LIBIDN2 */
17
18+#ifdef _WIN32
19+#include <WinHttp.h>
20+#endif
21+
22 #include "urldata.h"
23 #include "netrc.h"
24
25@@ -4586,6 +4590,21 @@
26 }
27
28 #ifndef CURL_DISABLE_HTTP
29+#ifdef _WIN32
30+static char *wstrToCstr(LPWSTR wStr)
31+{
32+  int bufSize;
33+  char *out = NULL;
34+  if(wStr != NULL) {
35+    bufSize = WideCharToMultiByte(
36+      CP_ACP,  0, wStr, -1, NULL, 0, NULL, NULL);
37+    out = (char *)malloc(bufSize * sizeof(char));
38+    WideCharToMultiByte(CP_ACP, 0, wStr, -1, out, bufSize, NULL, NULL);
39+  }
40+  return out;
41+}
42+#endif
43+
44 /****************************************************************
45 * Detect what (if any) proxy to use. Remember that this selects a host
46 * name and is not limited to HTTP proxies only.
47@@ -4613,6 +4633,66 @@
48    * For compatibility, the all-uppercase versions of these variables are
49    * checked if the lowercase versions don't exist.
50    */
51+#ifdef _WIN32
52+  char *no_proxy = NULL;
53+  WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *ieProxyConfig;
54+  ieProxyConfig = (WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *)
55+    malloc(sizeof(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG));
56+  if(WinHttpGetIEProxyConfigForCurrentUser(ieProxyConfig)) {
57+    if(!ieProxyConfig->fAutoDetect) {
58+      char *ieProxy;
59+      char *ieNoProxy;
60+      char *pos;
61+
62+      ieProxy = wstrToCstr(ieProxyConfig->lpszProxy);
63+      ieNoProxy = wstrToCstr(ieProxyConfig->lpszProxyBypass);
64+
65+      /* Convert the ieNoProxy into a proper no_proxy value */
66+      if(NULL != ieNoProxy) {
67+        no_proxy = strdup(ieNoProxy);
68+        pos = strpbrk(no_proxy, "; ");
69+        while(NULL != pos) {
70+          no_proxy[pos-no_proxy] = ',';
71+          pos = strpbrk(no_proxy, "; ");
72+        }
73+      }
74+
75+      if(!check_noproxy(conn->host.name, no_proxy)) {
76+        /* Look for the http proxy setting */
77+        char *tok;
78+        char *saveptr;
79+
80+        if(NULL != ieProxy) {
81+          tok = strtok_s(ieProxy, ";", &saveptr);
82+          if(strchr(tok, '=') == NULL) {
83+            proxy = strdup(ieProxy);
84+          }
85+          else {
86+            do {
87+              if(strncmp(tok, "http=", 5) == 0) {
88+                /* We found HTTP proxy value, then use it */
89+                proxy = strdup(tok + 5);
90+              }
91+              tok = strtok_s(NULL, ";", &saveptr);
92+            }
93+            while(NULL != tok);
94+          }
95+        }
96+      }
97+
98+      free(ieProxy);
99+      free(ieNoProxy);
100+    }
101+    else {
102+      /* TODO Handle the Proxy config Auto Detection case */
103+    }
104+
105+    GlobalFree(ieProxyConfig->lpszAutoConfigUrl);
106+    GlobalFree(ieProxyConfig->lpszProxy);
107+    GlobalFree(ieProxyConfig->lpszProxyBypass);
108+  }
109+  free(no_proxy);
110+#else /* !_WIN32 */
111   char proxy_env[128];
112   const char *protop = conn->handler->scheme;
113   char *envp = proxy_env;
114@@ -4663,6 +4739,7 @@
115   }
116   if(proxy)
117     infof(data, "Uses proxy env variable %s == '%s'", envp, proxy);
118+#endif /* _WIN32 */
119
120   return proxy;
121 }
122