From d408d54f23107e7e2eb1274c910c0e56977ef6fd Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Sun, 8 Jun 2008 16:56:35 +0300 Subject: [PATCH] HTTP access: support for libproxy, with configure autodetection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Libproxy can read proxy settings from KDE, GNOME, NetworkManager, or the environment. Signed-off-by: Rémi Denis-Courmont --- configure.ac | 15 +++++++++++++++ modules/access/http.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fd7bba26c5..7aecb5a65b 100644 --- a/configure.ac +++ b/configure.ac @@ -1665,6 +1665,21 @@ then fi AM_CONDITIONAL(BUILD_HTTPD, [test "${enable_httpd}" != "no"]) +dnl +dnl libproxy support +dnl +AC_ARG_ENABLE(libproxy, + [ --enable-libproxy libproxy support (default auto)]) +AS_IF([test "${enable_libproxy}" != "no"], [ + AC_CHECK_HEADERS(proxy.h, [ + VLC_ADD_LIBS([access_http],[-lproxy]) + ], [ + AS_IF([test "x${enable_libproxy}" != "x"], [ + AC_MSG_ERROR([libproxy could not be found on your system]) + ]) + ]) +]) + dnl dnl VideoLAN manager dnl diff --git a/modules/access/http.c b/modules/access/http.c index cfb207de76..e397a1f800 100644 --- a/modules/access/http.c +++ b/modules/access/http.c @@ -52,6 +52,9 @@ #include +#ifdef HAVE_PROXY_H +# include "proxy.h" +#endif /***************************************************************************** * Module descriptor *****************************************************************************/ @@ -315,7 +318,40 @@ static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies ) vlc_UrlParse( &p_sys->proxy, psz, 0 ); free( psz ); } -#ifdef HAVE_GETENV +#ifdef HAVE_PROXY_H + else + { + pxProxyFactory *pf = px_proxy_factory_new(); + if (pf) + { + char *buf; + int i; + i=asprintf(&buf, "%s://%s", p_access->psz_access, p_access->psz_path); + if (i >= 0) + { + msg_Dbg(p_access, "asking libproxy about url '%s'", buf); + char **proxies = px_proxy_factory_get_proxies(pf, buf); + if (proxies[0]) + { + msg_Dbg(p_access, "libproxy suggest to use '%s'", proxies[0]); + if(strcmp(proxies[0],"direct://") != 0) + { + p_sys->b_proxy = true; + vlc_UrlParse( &p_sys->proxy, proxies[0], 0); + } + } + for(i=0;proxies[i];i++) free(proxies[i]); + free(proxies); + free(buf); + px_proxy_factory_free(pf); + } + } + else + { + msg_Err(p_access, "Allocating memory for libproxy failed"); + } + } +#elif HAVE_GETENV else { psz = getenv( "http_proxy" ); -- 2.39.2