Commit ba42d310 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

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

(cherry picked from commit 28db7725)
parent 875f8c7c
...@@ -1239,44 +1239,22 @@ static int Request( access_t *p_access, uint64_t i_tell ) ...@@ -1239,44 +1239,22 @@ static int Request( access_t *p_access, uint64_t i_tell )
p_sys->b_persist = false; p_sys->b_persist = false;
p_sys->i_remaining = 0; p_sys->i_remaining = 0;
if( p_sys->b_proxy )
{ const char *psz_path = p_sys->url.psz_path;
if( p_sys->url.psz_path ) if( !psz_path || !*psz_path )
{ psz_path = "/";
net_Printf( p_access, p_sys->fd, NULL, net_Write( p_access, p_sys->fd, pvs, "GET ", 4 );
"GET http://%s:%d%s HTTP/1.%d\r\n", if( p_sys->b_proxy && pvs == NULL )
p_sys->url.psz_host, p_sys->url.i_port, net_Printf( p_access, p_sys->fd, NULL, "http://%s:%d",
p_sys->url.psz_path, p_sys->i_version ); p_sys->url.psz_host, p_sys->url.i_port );
} net_Printf( p_access, p_sys->fd, pvs, "%s HTTP/1.%d\r\n",
else psz_path, p_sys->i_version );
{ if( p_sys->url.i_port != (pvs ? 443 : 80) )
net_Printf( p_access, p_sys->fd, NULL, net_Printf( p_access, p_sys->fd, pvs, "Host: %s:%d\r\n",
"GET http://%s:%d/ HTTP/1.%d\r\n", p_sys->url.psz_host, p_sys->url.i_port );
p_sys->url.psz_host, p_sys->url.i_port,
p_sys->i_version );
}
}
else else
{ net_Printf( p_access, p_sys->fd, pvs, "Host: %s\r\n",
const char *psz_path = p_sys->url.psz_path; p_sys->url.psz_host );
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 );
}
}
/* User Agent */ /* User Agent */
net_Printf( p_access, p_sys->fd, pvs, net_Printf( p_access, p_sys->fd, pvs,
"User-Agent: %s\r\n", "User-Agent: %s\r\n",
......
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