[vlc-commits] http: refactor proxy query helper

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


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

http: refactor proxy query helper

Adds support for insecure origin servers.

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

 modules/access/http/connmgr.c |   29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/modules/access/http/connmgr.c b/modules/access/http/connmgr.c
index 7a0e4b1..d948e3f 100644
--- a/modules/access/http/connmgr.c
+++ b/modules/access/http/connmgr.c
@@ -34,27 +34,19 @@
 
 #pragma GCC visibility push(default)
 
-struct vlc_https_connecting
-{
-    vlc_tls_creds_t *creds;
-    const char *host;
-    unsigned port;
-    bool *http2;
-    vlc_sem_t done;
-};
-
-static char *vlc_https_proxy_find(const char *hostname, unsigned port)
+static char *vlc_http_proxy_find(const char *hostname, unsigned port,
+                                 bool secure)
 {
     const char *fmt;
     char *url, *proxy = NULL;
     int canc = vlc_savecancel();
 
     if (strchr(hostname, ':') != NULL)
-        fmt = port ? "https://[%s]:%u" : "https://[%s]";
+        fmt = port ? "http%s://[%s]:%u" : "http%s://[%s]";
     else
-        fmt = port ? "https://%s:%u" : "https://%s";
+        fmt = port ? "http%s://%s:%u" : "http%s://%s";
 
-    if (likely(asprintf(&url, fmt, hostname, port) >= 0))
+    if (likely(asprintf(&url, fmt, secure ? "s" : "", hostname, port) >= 0))
     {
         proxy = vlc_getProxyUrl(url);
         free(url);
@@ -63,12 +55,21 @@ static char *vlc_https_proxy_find(const char *hostname, unsigned port)
     return proxy;
 }
 
+struct vlc_https_connecting
+{
+    vlc_tls_creds_t *creds;
+    const char *host;
+    unsigned port;
+    bool *http2;
+    vlc_sem_t done;
+};
+
 static void *vlc_https_connect_thread(void *data)
 {
     struct vlc_https_connecting *c = data;
     vlc_tls_t *tls;
 
-    char *proxy = vlc_https_proxy_find(c->host, c->port);
+    char *proxy = vlc_http_proxy_find(c->host, c->port, true);
     if (proxy != NULL)
     {
         tls = vlc_https_connect_proxy(c->creds, c->host, c->port, c->http2,



More information about the vlc-commits mailing list