[vlc-commits] http: add proxy support for insecure origins (refs #16413)

Rémi Denis-Courmont git at videolan.org
Fri Jul 15 18:53:54 CEST 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jul 15 19:52:24 2016 +0300| [bc399b90a722a648895d44db871abb692abb0b57] | committer: Rémi Denis-Courmont

http: add proxy support for insecure origins (refs #16413)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bc399b90a722a648895d44db871abb692abb0b57
---

 modules/access/http/connmgr.c |   31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/modules/access/http/connmgr.c b/modules/access/http/connmgr.c
index d948e3f..47eeee8 100644
--- a/modules/access/http/connmgr.c
+++ b/modules/access/http/connmgr.c
@@ -27,6 +27,7 @@
 #include <vlc_network.h>
 #include <vlc_tls.h>
 #include <vlc_interrupt.h>
+#include <vlc_url.h>
 #include "transport.h"
 #include "conn.h"
 #include "connmgr.h"
@@ -118,6 +119,7 @@ struct vlc_http_connecting
     vlc_object_t *obj;
     const char *host;
     unsigned port;
+    bool *proxy;
     vlc_sem_t done;
 };
 
@@ -126,14 +128,33 @@ static void *vlc_http_connect_thread(void *data)
     struct vlc_http_connecting *c = data;
     vlc_tls_t *tls;
 
-    tls = vlc_http_connect(c->obj, c->host, c->port);
+    char *proxy = vlc_http_proxy_find(c->host, c->port, false);
+    if (proxy != NULL)
+    {
+        vlc_url_t url;
+
+        vlc_UrlParse(&url, proxy);
+        free(proxy);
+
+        if (url.psz_host != NULL)
+            tls = vlc_http_connect(c->obj, url.psz_host, url.i_port);
+        else
+            tls = NULL;
+
+        vlc_UrlClean(&url);
+    }
+    else
+        tls = vlc_http_connect(c->obj, c->host, c->port);
+
+    *(c->proxy) = proxy != NULL;
     vlc_sem_post(&c->done);
     return tls;
 }
 
 /** Interruptible vlc_http_connect() */
 static vlc_tls_t *vlc_http_connect_i11e(vlc_object_t *obj,
-                                        const char *host, unsigned port)
+                                        const char *host, unsigned port,
+                                        bool *restrict proxy)
 {
     struct vlc_http_connecting c;
     vlc_thread_t th;
@@ -141,6 +162,7 @@ static vlc_tls_t *vlc_http_connect_i11e(vlc_object_t *obj,
     c.obj = obj;
     c.host = host;
     c.port = port;
+    c.proxy = proxy;
     vlc_sem_init(&c.done, 0);
 
     if (vlc_clone(&th, vlc_http_connect_thread, &c, VLC_THREAD_PRIORITY_INPUT))
@@ -270,7 +292,8 @@ static struct vlc_http_msg *vlc_http_request(struct vlc_http_mgr *mgr,
     if (resp != NULL)
         return resp;
 
-    vlc_tls_t *tls = vlc_http_connect_i11e(mgr->obj, host, port);
+    bool proxy;
+    vlc_tls_t *tls = vlc_http_connect_i11e(mgr->obj, host, port, &proxy);
     if (tls == NULL)
         return NULL;
 
@@ -279,7 +302,7 @@ static struct vlc_http_msg *vlc_http_request(struct vlc_http_mgr *mgr,
     if (mgr->use_h2c)
         conn = vlc_h2_conn_create(tls);
     else
-        conn = vlc_h1_conn_create(tls, false);
+        conn = vlc_h1_conn_create(tls, proxy);
 
     if (unlikely(conn == NULL))
     {



More information about the vlc-commits mailing list