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

- support for Basic HTTP Proxy authentication (closes #149)

- getenv is case-sensitive !!! use HTTP_PROXY instead of http_proxy
parent 80d4c0ee
...@@ -45,8 +45,8 @@ static void Close( vlc_object_t * ); ...@@ -45,8 +45,8 @@ static void Close( vlc_object_t * );
#define PROXY_TEXT N_("HTTP proxy") #define PROXY_TEXT N_("HTTP proxy")
#define PROXY_LONGTEXT N_( \ #define PROXY_LONGTEXT N_( \
"You can specify an HTTP proxy to use. It must be of the form " \ "You can specify an HTTP proxy to use. It must be of the form " \
"http://myproxy.mydomain:myport/. If none is specified, the HTTP_PROXY " \ "http://[user[:pass]@]myproxy.mydomain:myport/ ; " \
"environment variable will be tried." ) "if empty, the HTTP_PROXY environment variable will be tried." )
#define CACHING_TEXT N_("Caching value in ms") #define CACHING_TEXT N_("Caching value in ms")
#define CACHING_LONGTEXT N_( \ #define CACHING_LONGTEXT N_( \
...@@ -237,7 +237,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -237,7 +237,7 @@ static int Open( vlc_object_t *p_this )
} }
if( !strncmp( p_access->psz_access, "https", 5 ) ) if( !strncmp( p_access->psz_access, "https", 5 ) )
{ {
/* SSL over HTTP */ /* HTTP over SSL */
p_sys->b_ssl = VLC_TRUE; p_sys->b_ssl = VLC_TRUE;
if( p_sys->url.i_port <= 0 ) if( p_sys->url.i_port <= 0 )
p_sys->url.i_port = 443; p_sys->url.i_port = 443;
...@@ -261,7 +261,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -261,7 +261,7 @@ static int Open( vlc_object_t *p_this )
#ifdef HAVE_GETENV #ifdef HAVE_GETENV
else else
{ {
char *psz_proxy = getenv( "http_proxy" ); char *psz_proxy = getenv( "HTTP_PROXY" );
if( psz_proxy && *psz_proxy ) if( psz_proxy && *psz_proxy )
{ {
p_sys->b_proxy = VLC_TRUE; p_sys->b_proxy = VLC_TRUE;
...@@ -927,7 +927,7 @@ static int Request( access_t *p_access, int64_t i_tell ) ...@@ -927,7 +927,7 @@ static int Request( access_t *p_access, int64_t i_tell )
"Range: bytes="I64Fd"-\r\n", i_tell ); "Range: bytes="I64Fd"-\r\n", i_tell );
} }
/* Authentification */ /* Authentication */
if( p_sys->url.psz_username && *p_sys->url.psz_username ) if( p_sys->url.psz_username && *p_sys->url.psz_username )
{ {
char *buf; char *buf;
...@@ -944,6 +944,23 @@ static int Request( access_t *p_access, int64_t i_tell ) ...@@ -944,6 +944,23 @@ static int Request( access_t *p_access, int64_t i_tell )
free( b64 ); free( b64 );
} }
/* Proxy Authentication */
if( p_sys->proxy.psz_username && *p_sys->proxy.psz_username )
{
char *buf;
char *b64;
asprintf( &buf, "%s:%s", p_sys->proxy.psz_username,
p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" );
b64 = vlc_b64_encode( buf );
free( buf );
net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
"Proxy-Authorization: Basic %s\r\n", b64 );
free( b64 );
}
/* ICY meta data request */ /* ICY meta data request */
net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "Icy-MetaData: 1\r\n" ); net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, "Icy-MetaData: 1\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