Bump version to 5.0-14
[LibreOffice.git] / external / curl / curl-7.26.0_win-proxy.patch
blob99402a437e5a21c99e35f9e37832f0c65d8111df
1 --- curl-7.26.0/lib/Makefile.vc10
2 +++ misc/build/curl-7.26.0/lib/Makefile.vc10
3 @@ -116,7 +116,7 @@ LFLAGS = /nologo /machine:$(MACHINE)
4 SSLLIBS = libeay32.lib ssleay32.lib
5 ZLIBLIBSDLL = zdll.lib
6 ZLIBLIBS = zlib.lib
7 -WINLIBS = ws2_32.lib wldap32.lib advapi32.lib
8 +WINLIBS = ws2_32.lib wldap32.lib advapi32.lib winhttp.lib
9 CFLAGS = $(CFLAGS) $(EXCFLAGS)
11 CFGSET = FALSE
12 --- curl-7.26.0/lib/url.c
13 +++ misc/build/curl-7.26.0/lib/url.c
14 @@ -80,6 +80,10 @@ void idn_free (void *ptr);
15 int curl_win32_idn_to_ascii(const char *in, char **out);
16 #endif /* USE_LIBIDN */
18 +#ifdef WIN32
19 +#include <WinHttp.h>
20 +#endif
22 #include "urldata.h"
23 #include "netrc.h"
25 @@ -4111,6 +4115,21 @@ static bool check_noproxy(const char* name, const char* no_proxy)
26 return FALSE;
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 @@ -4119,6 +4138,7 @@ static bool check_noproxy(const char* name, const char* no_proxy)
48 static char *detect_proxy(struct connectdata *conn)
50 char *proxy = NULL;
51 + char *no_proxy=NULL;
53 #ifndef CURL_DISABLE_HTTP
54 /* If proxy was not specified, we check for default proxy environment
55 @@ -4138,7 +4158,63 @@ static char *detect_proxy(struct connectdata *conn)
56 * For compatibility, the all-uppercase versions of these variables are
57 * checked if the lowercase versions don't exist.
59 - char *no_proxy=NULL;
60 +#ifdef WIN32
61 + WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *ieProxyConfig;
62 + ieProxyConfig = (WINHTTP_CURRENT_USER_IE_PROXY_CONFIG*)
63 + malloc(sizeof(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG));
64 + if(WinHttpGetIEProxyConfigForCurrentUser(ieProxyConfig)) {
65 + if(!ieProxyConfig->fAutoDetect) {
66 + char *ieProxy;
67 + char *ieNoProxy;
68 + char* pos;
70 + ieProxy = wstrToCstr(ieProxyConfig->lpszProxy);
71 + ieNoProxy = wstrToCstr(ieProxyConfig->lpszProxyBypass);
73 + /* Convert the ieNoProxy into a proper no_proxy value */
74 + if(NULL != ieNoProxy) {
75 + no_proxy = strdup(ieNoProxy);
76 + pos = strpbrk(no_proxy, "; ");
77 + while(NULL != pos) {
78 + no_proxy[pos-no_proxy] = ',';
79 + pos = strpbrk(no_proxy, "; ");
80 + }
81 + }
83 + if(!check_noproxy(conn->host.name, no_proxy)) {
84 + /* Look for the http proxy setting */
85 + char* tok;
87 + if(NULL != ieProxy) {
88 + tok = strtok(ieProxy, ";");
89 + if(strchr(tok, '=') == NULL) {
90 + proxy = strdup(ieProxy);
91 + }
92 + else {
93 + do {
94 + if(strncmp(tok, "http=", 5) == 0) {
95 + /* We found HTTP proxy value, then use it */
96 + proxy = strdup( tok + 5 );
97 + }
98 + tok = strtok(NULL, ";");
99 + }
100 + while(NULL != tok);
105 + free(ieProxy);
106 + free(ieNoProxy);
108 + else {
109 + /* TODO Handle the Proxy config Auto Detection case */
112 + GlobalFree( ieProxyConfig->lpszAutoConfigUrl );
113 + GlobalFree( ieProxyConfig->lpszProxy );
114 + GlobalFree( ieProxyConfig->lpszProxyBypass );
116 +#else /* !WIN32 */
117 char proxy_env[128];
119 no_proxy=curl_getenv("no_proxy");
120 @@ -4189,6 +4265,7 @@ static char *detect_proxy(struct connectdata *conn)
122 } /* if(!check_noproxy(conn->host.name, no_proxy)) - it wasn't specified
123 non-proxy */
124 +#endif /* WIN32 */
125 free(no_proxy);
127 #else /* !CURL_DISABLE_HTTP */