[vlc-commits] http: fix URLs with query and without path

Rémi Denis-Courmont git at videolan.org
Thu Aug 27 20:38:20 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Aug 27 19:35:59 2015 +0300| [75e2a6cf58b956a429f201d93bff5d13337a6eff] | committer: Rémi Denis-Courmont

http: fix URLs with query and without path

Previously, VLC would treat the query as part of the host name, leading
to host name resolution failure.

E.g.: http://www.example.com?opt1=value1&opt2=value2

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

 modules/access/http.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/modules/access/http.c b/modules/access/http.c
index cb6ee0c..08d341f 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -287,7 +287,7 @@ static int OpenRedirected( vlc_object_t *p_this, const char *psz_access,
     p = psz = strdup( p_access->psz_location );
     while( (p = strchr( p, ' ' )) != NULL )
         *p = '+';
-    vlc_UrlParse( &p_sys->url, psz, 0 );
+    vlc_UrlParse( &p_sys->url, psz, '?' );
     free( psz );
 
     if( p_sys->url.psz_host == NULL || *p_sys->url.psz_host == '\0' )
@@ -372,7 +372,7 @@ static int OpenRedirected( vlc_object_t *p_this, const char *psz_access,
     if( psz != NULL )
     {
         p_sys->b_proxy = true;
-        vlc_UrlParse( &p_sys->proxy, psz, 0 );
+        vlc_UrlParse( &p_sys->proxy, psz, '?' );
         free( psz );
 
         psz = var_InheritString( p_access, "http-proxy-pwd" );
@@ -1121,12 +1121,16 @@ static int Request( access_t *p_access, uint64_t i_tell )
     if( !psz_path || !*psz_path )
         psz_path = "/";
     if( p_sys->b_proxy && p_sys->p_tls == NULL )
-        WriteHeaders( p_access, "GET http://%s:%d%s HTTP/1.%d\r\n",
+        WriteHeaders( p_access, "GET http://%s:%d%s%s%s HTTP/1.%d\r\n",
                       p_sys->url.psz_host, p_sys->url.i_port,
-                      psz_path, p_sys->i_version );
+                      psz_path, p_sys->url.psz_option ? "?" : "",
+                      p_sys->url.psz_option ? p_sys->url.psz_option : "",
+                      p_sys->i_version );
     else
-        WriteHeaders( p_access, "GET %s HTTP/1.%d\r\n",
-                      psz_path, p_sys->i_version );
+        WriteHeaders( p_access, "GET %s%s%s HTTP/1.%d\r\n",
+                      psz_path, p_sys->url.psz_option ? "?" : "",
+                      p_sys->url.psz_option ? p_sys->url.psz_option : "",
+                      p_sys->i_version );
     if( p_sys->url.i_port != (p_sys->p_tls ? 443 : 80) )
         WriteHeaders( p_access, "Host: %s:%d\r\n",
                       p_sys->url.psz_host, p_sys->url.i_port );



More information about the vlc-commits mailing list