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

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Oct 24 20:38:43 CEST 2010


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?

> @@ -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.


More information about the MPlayer-dev-eng mailing list