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

Fix HTTP authentication.

Yes, some sites use empty usernames
parent db9ec109
...@@ -932,37 +932,41 @@ static int Request( access_t *p_access, int64_t i_tell ) ...@@ -932,37 +932,41 @@ static int Request( access_t *p_access, int64_t i_tell )
} }
/* Authentication */ /* Authentication */
if( p_sys->url.psz_username && *p_sys->url.psz_username ) if( p_sys->url.psz_username || p_sys->url.psz_password )
{ {
char *buf; char buf[strlen( p_sys->url.psz_username ?: "" )
+ strlen( p_sys->url.psz_password ?: "" ) + 2];
char *b64; char *b64;
asprintf( &buf, "%s:%s", p_sys->url.psz_username, snprintf( buf, sizeof( buf ), "%s:%s", p_sys->url.psz_username ?: "",
p_sys->url.psz_password ? p_sys->url.psz_password : "" ); p_sys->url.psz_password ?: "" );
b64 = vlc_b64_encode( buf ); b64 = vlc_b64_encode( buf );
free( buf );
net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, if( b64 != NULL )
"Authorization: Basic %s\r\n", b64 ); {
free( b64 ); net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
"Authorization: Basic %s\r\n", b64 );
free( b64 );
}
} }
/* Proxy Authentication */ /* Proxy Authentication */
if( p_sys->proxy.psz_username && *p_sys->proxy.psz_username ) if( p_sys->proxy.psz_username || p_sys->proxy.psz_password )
{ {
char *buf; char buf[strlen( p_sys->proxy.psz_username ?: "" )
+ strlen( p_sys->proxy.psz_password ?: "" )];
char *b64; char *b64;
asprintf( &buf, "%s:%s", p_sys->proxy.psz_username, snprintf( buf, sizeof( buf ), "%s:%s", p_sys->proxy.psz_username ?: "",
p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" ); p_sys->proxy.psz_password ?: "" );
b64 = vlc_b64_encode( buf ); b64 = vlc_b64_encode( buf );
free( buf );
net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs, if( b64 != NULL)
"Proxy-Authorization: Basic %s\r\n", b64 ); {
free( b64 ); 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 */
......
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