[MPlayer-dev-eng] [PATCH 3/7] Use authorization field to pass server authentication through proxy

Clément Bœsch ubitux at gmail.com
Sun Oct 24 21:44:56 CEST 2010


On Sun, Oct 24, 2010 at 08:38:43PM +0200, Reimar Döffinger wrote:
> On Mon, Oct 18, 2010 at 12:05:53PM +0200, Clément Bœsch wrote:
> > Currently, http_proxy:// does not forward server auth correcly, here is
> > a fix.
> > ---
> >  stream/network.c |   13 ++++++++++---
> >  1 files changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/stream/network.c b/stream/network.c
> > index 9f81609..1ec1220 100644
> > --- a/stream/network.c
> > +++ b/stream/network.c
> > @@ -209,7 +209,11 @@ http_send_request( URL_t *url, off_t pos ) {
> >  			mp_msg(MSGT_NETWORK, MSGL_ERR, "Invalid URL '%s' to proxify\n", url->file+1);
> >  			goto err_out;
> >  		}
> > -		http_set_uri( http_hdr, server_url->url );
> > +		snprintf(str, 256, "http://%s:%d%s",
> > +				server_url->hostname,
> > +				server_url->port ? server_url->port : 80,
> > +				server_url->file);
> > +		http_set_uri( http_hdr, str );
> 
> What is going wrong here, what is in server_url->url?
> 

http://login:password@host:8000/foo.ogg instead of
http://host:8000/foo.ogg

Authentication must be passed through Authentication header. This explains
the diff below.

> > @@ -254,10 +258,13 @@ http_send_request( URL_t *url, off_t pos ) {
> >  	if (network_cookies_enabled) cookies_set( http_hdr, server_url->hostname, server_url->url );
> >  
> >  	http_set_field( http_hdr, "Connection: close");
> > -	if (proxy)
> > +	if (proxy) {
> >  		http_add_basic_proxy_authentication( http_hdr, url->username, url->password );
> > -	else
> > +		if (server_url->username && server_url->password)
> > +			http_add_basic_authentication( http_hdr, server_url->username, server_url->password );
> > +	} else {
> >  		http_add_basic_authentication( http_hdr, url->username, url->password );
> > +	}
> 
> There's no need to add {} for the else part.
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng

-- 
Clément B.
Not sent from a jesusPhone.


More information about the MPlayer-dev-eng mailing list