[vlc-commits] http: add missing Host field to proxied requests (fix #6388)

Rémi Denis-Courmont git at videolan.org
Sat Mar 24 17:53:13 CET 2012


vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 24 18:52:22 2012 +0200| [ba42d3103fd4d1ddf2a8010b9bed5bc3312e236b] | committer: Rémi Denis-Courmont

http: add missing Host field to proxied requests (fix #6388)

(cherry picked from commit 28db77258e69b7931d24677d25a02c073c9f2a7f)

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

 modules/access/http.c |   52 ++++++++++++++----------------------------------
 1 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/modules/access/http.c b/modules/access/http.c
index a292ebb..507143e 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -1239,44 +1239,22 @@ static int Request( access_t *p_access, uint64_t i_tell )
     p_sys->b_persist = false;
 
     p_sys->i_remaining = 0;
-    if( p_sys->b_proxy )
-    {
-        if( p_sys->url.psz_path )
-        {
-            net_Printf( p_access, p_sys->fd, NULL,
-                        "GET http://%s:%d%s HTTP/1.%d\r\n",
-                        p_sys->url.psz_host, p_sys->url.i_port,
-                        p_sys->url.psz_path, p_sys->i_version );
-        }
-        else
-        {
-            net_Printf( p_access, p_sys->fd, NULL,
-                        "GET http://%s:%d/ HTTP/1.%d\r\n",
-                        p_sys->url.psz_host, p_sys->url.i_port,
-                        p_sys->i_version );
-        }
-    }
+
+    const char *psz_path = p_sys->url.psz_path;
+    if( !psz_path || !*psz_path )
+        psz_path = "/";
+    net_Write( p_access, p_sys->fd, pvs, "GET ", 4 );
+    if( p_sys->b_proxy && pvs == NULL )
+        net_Printf( p_access, p_sys->fd, NULL, "http://%s:%d",
+                    p_sys->url.psz_host, p_sys->url.i_port );
+    net_Printf( p_access, p_sys->fd, pvs, "%s HTTP/1.%d\r\n",
+                psz_path, p_sys->i_version );
+    if( p_sys->url.i_port != (pvs ? 443 : 80) )
+        net_Printf( p_access, p_sys->fd, pvs, "Host: %s:%d\r\n",
+                    p_sys->url.psz_host, p_sys->url.i_port );
     else
-    {
-        const char *psz_path = p_sys->url.psz_path;
-        if( !psz_path || !*psz_path )
-        {
-            psz_path = "/";
-        }
-        if( p_sys->url.i_port != (pvs ? 443 : 80) )
-        {
-            net_Printf( p_access, p_sys->fd, pvs,
-                        "GET %s HTTP/1.%d\r\nHost: %s:%d\r\n",
-                        psz_path, p_sys->i_version, p_sys->url.psz_host,
-                        p_sys->url.i_port );
-        }
-        else
-        {
-            net_Printf( p_access, p_sys->fd, pvs,
-                        "GET %s HTTP/1.%d\r\nHost: %s\r\n",
-                        psz_path, p_sys->i_version, p_sys->url.psz_host );
-        }
-    }
+        net_Printf( p_access, p_sys->fd, pvs, "Host: %s\r\n",
+                    p_sys->url.psz_host );
     /* User Agent */
     net_Printf( p_access, p_sys->fd, pvs,
                 "User-Agent: %s\r\n",



More information about the vlc-commits mailing list