[vlc-devel] [PATCH] HTTP win32: use http-proxy options to setup the proxy

Jean-Baptiste Kempf jb at videolan.org
Fri Feb 2 17:27:29 CET 2018


Because win32/netconf is not ready
---
 modules/access/http.c | 15 ---------------
 src/libvlc-module.c   | 22 ++++++++++++++++++++++
 src/win32/netconf.c   | 24 +++++++++++++++++++++++-
 3 files changed, 45 insertions(+), 16 deletions(-)

diff --git a/modules/access/http.c b/modules/access/http.c
index 8d050bdec6..f5b4eacbd1 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -56,16 +56,6 @@
 static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
-#define PROXY_TEXT N_("HTTP proxy")
-#define PROXY_LONGTEXT N_( \
-    "HTTP proxy to be used It must be of the form " \
-    "http://[user@]myproxy.mydomain:myport/ ; " \
-    "if empty, the http_proxy environment variable will be tried." )
-
-#define PROXY_PASS_TEXT N_("HTTP proxy password")
-#define PROXY_PASS_LONGTEXT N_( \
-    "If your HTTP proxy requires a password, set it here." )
-
 #define RECONNECT_TEXT N_("Auto re-connect")
 #define RECONNECT_LONGTEXT N_( \
     "Automatically try to reconnect to the stream in case of a sudden " \
@@ -78,11 +68,6 @@ vlc_module_begin ()
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_ACCESS )
 
-    add_string( "http-proxy", NULL, PROXY_TEXT, PROXY_LONGTEXT,
-                false )
-    add_password( "http-proxy-pwd", NULL,
-                  PROXY_PASS_TEXT, PROXY_PASS_LONGTEXT, false )
-    add_obsolete_bool( "http-use-IE-proxy" )
     add_bool( "http-reconnect", false, RECONNECT_TEXT,
               RECONNECT_LONGTEXT, true )
     /* 'itpc' = iTunes Podcast */
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 9d29d24b4e..77ab8283ab 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -844,6 +844,16 @@ static const char *const ppsz_prefres[] = {
 #define KEY_LONGTEXT N_( \
    "This private key file (PEM format) is used for server-side TLS.")
 
+#define PROXY_TEXT N_("HTTP proxy")
+#define PROXY_LONGTEXT N_( \
+    "HTTP proxy to be used It must be of the form " \
+    "http://[user@]myproxy.mydomain:myport/ ; " \
+    "if empty, the http_proxy environment variable will be tried." )
+
+#define PROXY_PASS_TEXT N_("HTTP proxy password")
+#define PROXY_PASS_LONGTEXT N_( \
+    "If your HTTP proxy requires a password, set it here." )
+
 #define SOCKS_SERVER_TEXT N_("SOCKS server")
 #define SOCKS_SERVER_LONGTEXT N_( \
     "SOCKS proxy server to use. This must be of the form " \
@@ -1802,6 +1812,18 @@ vlc_module_begin ()
     add_obsolete_string( "http-crl" ) /* since 3.0.0 */
     add_obsolete_string( "sout-http-crl" ) /* since 2.0.0 */
 
+#ifdef _WIN32
+    add_string( "http-proxy", NULL, PROXY_TEXT, PROXY_LONGTEXT,
+                false )
+    add_password( "http-proxy-pwd", NULL,
+                  PROXY_PASS_TEXT, PROXY_PASS_LONGTEXT, false )
+#else
+    add_obsolete_string( "http-proxy" )
+    add_obsolete_string( "http-proxy-pwd" )
+
+#endif
+    add_obsolete_bool( "http-use-IE-proxy" )
+
     set_section( N_( "Socks proxy") , NULL )
     add_string( "socks", NULL,
                  SOCKS_SERVER_TEXT, SOCKS_SERVER_LONGTEXT, true )
diff --git a/src/win32/netconf.c b/src/win32/netconf.c
index accdddf2ce..0827376132 100644
--- a/src/win32/netconf.c
+++ b/src/win32/netconf.c
@@ -27,10 +27,32 @@
 
 #include <vlc_common.h>
 #include <vlc_network.h>
+#include <vlc_url.h>
 
 char *vlc_getProxyUrl(const char *url)
 {
-    char *proxy_url = NULL;
+    VLC_UNUSED(url);
+    char *proxy = config_GetPsz( (vlc_object_t *)(NULL), "http-proxy" );
+    char *proxy_pwd = config_GetPsz( (vlc_object_t *)(NULL), "http-proxy-pwd" );
+
+    if (proxy == NULL)
+        return NULL;
+
+    if (proxy_pwd == NULL)
+        return proxy;
+
+    vlc_url_t p_url;
+    if (vlc_UrlParse(&p_url, proxy) < 0)
+        return NULL;
+
+    if (p_url.psz_password == NULL )
+        p_url.psz_password = proxy_pwd;
+    else
+        free (proxy_pwd);
+
+    char *proxy_url = vlc_uri_compose (&p_url);
+    vlc_UrlClean (&p_url);
+
 #if 0
     /* Try to get the proxy server address from Windows internet settings. */
     HKEY h_key;
-- 
2.15.1



More information about the vlc-devel mailing list