On Sun, Oct 24, 2010 at 09:44:56PM +0200, Clément Bœsch wrote:
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
At least I think it should use server_url->protocol instead of a fixed "http".
@@ -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 ); + }
In the !proxy case server_url == url, and http_add_basic_authentication works with NULL password and is a NOP with NULL username, thus this whole code should be if (proxy) http_add_basic_proxy_authentication(http_hdr, url->username, url->password); http_add_basic_authentication(http_hdr, server_url->username, server_url->password);