curl: upgrade to release 7.78.0
[LibreOffice.git] / external / curl / curl-7.26.0_win-proxy.patch
blob5bb98fa0474176ad4fef484135c4eb0ac1352b6a
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 @@
5 CFLAGS_LIBCURL_STATIC = /DCURL_STATICLIB
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
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 */
18 +#ifdef _WIN32
19 +#include <WinHttp.h>
20 +#endif
22 #include "urldata.h"
23 #include "netrc.h"
25 @@ -4586,6 +4590,21 @@
28 #ifndef CURL_DISABLE_HTTP
29 +#ifdef _WIN32
30 +static char *wstrToCstr(LPWSTR wStr)
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;
42 +#endif
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.
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;
62 + ieProxy = wstrToCstr(ieProxyConfig->lpszProxy);
63 + ieNoProxy = wstrToCstr(ieProxyConfig->lpszProxyBypass);
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 + }
75 + if(!check_noproxy(conn->host.name, no_proxy)) {
76 + /* Look for the http proxy setting */
77 + char *tok;
78 + char *saveptr;
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 + }
98 + free(ieProxy);
99 + free(ieNoProxy);
101 + else {
102 + /* TODO Handle the Proxy config Auto Detection case */
105 + GlobalFree(ieProxyConfig->lpszAutoConfigUrl);
106 + GlobalFree(ieProxyConfig->lpszProxy);
107 + GlobalFree(ieProxyConfig->lpszProxyBypass);
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 @@
116 if(proxy)
117 infof(data, "Uses proxy env variable %s == '%s'", envp, proxy);
118 +#endif /* WIN32 */
120 return proxy;