[PATCH] Support login/password in http_proxy env variable

Clément Bœsch ubitux at gmail.com
Wed Oct 20 11:54:40 CEST 2010


---
 stream/network.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/stream/network.c b/stream/network.c
index d78df29..518c727 100644
--- a/stream/network.c
+++ b/stream/network.c
@@ -169,13 +169,20 @@ check4proxies( URL_t *url ) {
 
 			mp_msg(MSGT_NETWORK,MSGL_V,"Using HTTP proxy: %s\n", proxy_url->url );
 			len = strlen( proxy_url->hostname ) + strlen( url->url ) + 20;	// 20 = http_proxy:// + port
+			if (proxy_url->username && proxy_url->password)
+				len += strlen(proxy_url->username) + 1 + strlen(proxy_url->password) + 1; // u:p@
 			new_url = malloc( len+1 );
 			if( new_url==NULL ) {
 				mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 				url_free(proxy_url);
 				return url_out;
 			}
-			sprintf(new_url, "http_proxy://%s:%d/%s", proxy_url->hostname, proxy_url->port, url->url );
+			if (proxy_url->username && proxy_url->password)
+				sprintf(new_url, "http_proxy://%s:%s@%s:%d/%s",
+						proxy_url->username, proxy_url->password,
+						proxy_url->hostname, proxy_url->port, url->url );
+			else
+				sprintf(new_url, "http_proxy://%s:%d/%s", proxy_url->hostname, proxy_url->port, url->url );
 			tmp_url = url_new( new_url );
 			if( tmp_url==NULL ) {
 				free( new_url );
-- 
1.7.3.1


--gKMricLos+KVdGMg--


More information about the MPlayer-dev-eng mailing list