Commit 75e2a6cf authored by Rémi Denis-Courmont's avatar 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
parent 1a31763e
......@@ -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 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment