Commit f92e805b authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

access/http.c: Put cookies handling in a disabled by default option, at least...

access/http.c: Put cookies handling in a disabled by default option, at least until cookies handling is no more a hack.
parent 14764a96
...@@ -71,6 +71,9 @@ static void Close( vlc_object_t * ); ...@@ -71,6 +71,9 @@ static void Close( vlc_object_t * );
"You should not globally enable this option as it will break all other " \ "You should not globally enable this option as it will break all other " \
"types of HTTP streams." ) "types of HTTP streams." )
#define FORWARD_COOKIES_TEXT N_("Forward Cookies")
#define FORWARD_COOKIES_LONGTEXT N_("Forward Cookies Across http redirections ")
vlc_module_begin(); vlc_module_begin();
set_description( _("HTTP input") ); set_description( _("HTTP input") );
set_capability( "access2", 0 ); set_capability( "access2", 0 );
...@@ -88,6 +91,8 @@ vlc_module_begin(); ...@@ -88,6 +91,8 @@ vlc_module_begin();
RECONNECT_LONGTEXT, VLC_TRUE ); RECONNECT_LONGTEXT, VLC_TRUE );
add_bool( "http-continuous", 0, NULL, CONTINUOUS_TEXT, add_bool( "http-continuous", 0, NULL, CONTINUOUS_TEXT,
CONTINUOUS_LONGTEXT, VLC_TRUE ); CONTINUOUS_LONGTEXT, VLC_TRUE );
add_bool( "http-forward-cookies", 0, NULL, FORWARD_COOKIES_TEXT,
FORWARD_COOKIES_LONGTEXT, VLC_TRUE );
add_obsolete_string("http-user"); add_obsolete_string("http-user");
add_obsolete_string("http-pwd"); add_obsolete_string("http-pwd");
add_shortcut( "http" ); add_shortcut( "http" );
...@@ -176,8 +181,9 @@ static int OpenWithRedirectionStatus( vlc_object_t *p_this, vlc_bool_t b_is_from ...@@ -176,8 +181,9 @@ static int OpenWithRedirectionStatus( vlc_object_t *p_this, vlc_bool_t b_is_from
access_t *p_access = (access_t*)p_this; access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys; access_sys_t *p_sys;
char *psz, *p; char *psz, *p;
/* Only forward an store cookies if the corresponding option is activated */
vlc_array_t * saved_cookies = b_is_from_redirection ? p_access->p_sys->cookies : vlc_array_new(); vlc_bool_t b_forward_cookies = var_CreateGetBool( p_access, "http-forward-cookies" );
vlc_array_t * saved_cookies = b_forward_cookies ? (b_is_from_redirection ? p_access->p_sys->cookies : vlc_array_new()) : NULL;
/* Set up p_access */ /* Set up p_access */
STANDARD_READ_ACCESS_INIT; STANDARD_READ_ACCESS_INIT;
...@@ -200,6 +206,7 @@ static int OpenWithRedirectionStatus( vlc_object_t *p_this, vlc_bool_t b_is_from ...@@ -200,6 +206,7 @@ static int OpenWithRedirectionStatus( vlc_object_t *p_this, vlc_bool_t b_is_from
p_sys->psz_icy_genre = NULL; p_sys->psz_icy_genre = NULL;
p_sys->psz_icy_title = NULL; p_sys->psz_icy_title = NULL;
p_sys->i_remaining = 0; p_sys->i_remaining = 0;
p_sys->cookies = saved_cookies; p_sys->cookies = saved_cookies;
/* Parse URI - remove spaces */ /* Parse URI - remove spaces */
...@@ -458,10 +465,13 @@ static void Close( vlc_object_t *p_this ) ...@@ -458,10 +465,13 @@ static void Close( vlc_object_t *p_this )
Disconnect( p_access ); Disconnect( p_access );
if( p_sys->cookies )
{
int i; int i;
for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ ) for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ )
free(vlc_array_item_at_index( p_sys->cookies, i )); free(vlc_array_item_at_index( p_sys->cookies, i ));
vlc_array_destroy( p_sys->cookies ); vlc_array_destroy( p_sys->cookies );
}
free( p_sys ); free( p_sys );
} }
...@@ -948,6 +958,8 @@ static int Request( access_t *p_access, int64_t i_tell ) ...@@ -948,6 +958,8 @@ static int Request( access_t *p_access, int64_t i_tell )
} }
/* Cookies */ /* Cookies */
if( p_sys->cookies )
{
int i; int i;
for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ ) for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ )
{ {
...@@ -966,6 +978,7 @@ static int Request( access_t *p_access, int64_t i_tell ) ...@@ -966,6 +978,7 @@ static int Request( access_t *p_access, int64_t i_tell )
free( psz_cookie_content ); free( psz_cookie_content );
free( psz_cookie_domain ); free( psz_cookie_domain );
} }
}
/* Authentication */ /* Authentication */
if( p_sys->url.psz_username || p_sys->url.psz_password ) if( p_sys->url.psz_username || p_sys->url.psz_password )
...@@ -1220,10 +1233,15 @@ static int Request( access_t *p_access, int64_t i_tell ) ...@@ -1220,10 +1233,15 @@ static int Request( access_t *p_access, int64_t i_tell )
{ {
msg_Dbg( p_access, "Meta-Info: %s: %s", psz, p ); msg_Dbg( p_access, "Meta-Info: %s: %s", psz, p );
} else if( !strcasecmp( psz, "Set-Cookie" ) ) } else if( !strcasecmp( psz, "Set-Cookie" ) )
{
if( p_sys->cookies )
{ {
msg_Dbg( p_access, "Accepting Cookie: %s", p ); msg_Dbg( p_access, "Accepting Cookie: %s", p );
cookie_append( p_sys->cookies, strdup(p) ); cookie_append( p_sys->cookies, strdup(p) );
} }
else
msg_Dbg( p_access, "We have a Cookie we won't remember: %s", p );
}
free( psz ); free( psz );
} }
......
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