[vlc-commits] http: use vlc_h1_request() (fixes #16067)

Rémi Denis-Courmont git at videolan.org
Sat Mar 4 18:56:02 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar  4 19:51:09 2017 +0200| [567b1f13d6fe7763301e1132cd453a4f7f2f9eca] | committer: Rémi Denis-Courmont

http: use vlc_h1_request() (fixes #16067)

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

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

diff --git a/modules/access/http/connmgr.c b/modules/access/http/connmgr.c
index 5554744..5e38442 100644
--- a/modules/access/http/connmgr.c
+++ b/modules/access/http/connmgr.c
@@ -110,35 +110,6 @@ static vlc_tls_t *vlc_https_connect_i11e(vlc_tls_creds_t *creds,
     return tls;
 }
 
-static vlc_tls_t *vlc_http_connect_i11e(vlc_object_t *obj,
-                                        const char *host, unsigned port,
-                                        bool *restrict proxied)
-{
-    vlc_tls_t *tls;
-
-    char *proxy = vlc_http_proxy_find(host, port, false);
-    if (proxy != NULL)
-    {
-        vlc_url_t url;
-
-        vlc_UrlParse(&url, proxy);
-        free(proxy);
-
-        if (url.psz_host != NULL)
-            tls =vlc_tls_SocketOpenTCP(obj, url.psz_host,
-                                       url.i_port ? url.i_port : 80);
-        else
-            tls = NULL;
-
-        vlc_UrlClean(&url);
-    }
-    else
-        tls = vlc_tls_SocketOpenTCP(obj, host, port ? port : 80);
-
-    *proxied = proxy != NULL;
-    return tls;
-}
-
 
 struct vlc_http_mgr
 {
@@ -251,27 +222,42 @@ static struct vlc_http_msg *vlc_http_request(struct vlc_http_mgr *mgr,
     if (resp != NULL)
         return resp;
 
-    bool proxy;
-    vlc_tls_t *tls = vlc_http_connect_i11e(mgr->obj, host, port, &proxy);
-    if (tls == NULL)
-        return NULL;
-
     struct vlc_http_conn *conn;
+    struct vlc_http_stream *stream;
 
-    if (mgr->use_h2c)
-        conn = vlc_h2_conn_create(mgr->obj, tls);
+    char *proxy = vlc_http_proxy_find(host, port, false);
+    if (proxy != NULL)
+    {
+        vlc_url_t url;
+
+        vlc_UrlParse(&url, proxy);
+        free(proxy);
+
+        if (url.psz_host != NULL)
+            stream = vlc_h1_request(mgr->obj, url.psz_host,
+                                    url.i_port ? url.i_port : 80, true, req,
+                                    true, &conn);
+        else
+            stream = NULL;
+
+        vlc_UrlClean(&url);
+    }
     else
-        conn = vlc_h1_conn_create(mgr->obj, tls, proxy);
+        stream = vlc_h1_request(mgr->obj, host, port ? port : 80, false, req,
+                                true, &conn);
 
-    if (unlikely(conn == NULL))
+    if (stream == NULL)
+        return NULL;
+
+    resp = vlc_http_msg_get_initial(stream);
+    if (resp == NULL)
     {
-        vlc_tls_Close(tls);
+        vlc_http_conn_release(conn);
         return NULL;
     }
 
     mgr->conn = conn;
-
-    return vlc_http_mgr_reuse(mgr, host, port, req);
+    return resp;
 }
 
 struct vlc_http_msg *vlc_http_mgr_request(struct vlc_http_mgr *mgr, bool https,



More information about the vlc-commits mailing list