Commit ef7a981f authored by Jonas Gehring's avatar Jonas Gehring Committed by Jean-Baptiste Kempf

Add http-referrer option to HTTP access module

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 2afaacab
...@@ -119,6 +119,8 @@ vlc_module_begin () ...@@ -119,6 +119,8 @@ vlc_module_begin ()
add_integer( "http-caching", 4 * DEFAULT_PTS_DELAY / 1000, add_integer( "http-caching", 4 * DEFAULT_PTS_DELAY / 1000,
CACHING_TEXT, CACHING_LONGTEXT, true ) CACHING_TEXT, CACHING_LONGTEXT, true )
change_safe() change_safe()
add_string( "http-referrer", NULL, NULL, NULL, false )
change_safe()
add_string( "http-user-agent", NULL, NULL, NULL, false ) add_string( "http-user-agent", NULL, NULL, NULL, false )
change_safe() change_safe()
change_private() change_private()
...@@ -156,6 +158,7 @@ struct access_sys_t ...@@ -156,6 +158,7 @@ struct access_sys_t
/* From uri */ /* From uri */
vlc_url_t url; vlc_url_t url;
char *psz_user_agent; char *psz_user_agent;
char *psz_referrer;
http_auth_t auth; http_auth_t auth;
/* Proxy */ /* Proxy */
...@@ -281,6 +284,7 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access, ...@@ -281,6 +284,7 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
p_sys->b_icecast = false; p_sys->b_icecast = false;
p_sys->psz_location = NULL; p_sys->psz_location = NULL;
p_sys->psz_user_agent = NULL; p_sys->psz_user_agent = NULL;
p_sys->psz_referrer = NULL;
p_sys->b_pace_control = true; p_sys->b_pace_control = true;
p_sys->b_ssl = false; p_sys->b_ssl = false;
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
...@@ -350,6 +354,9 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access, ...@@ -350,6 +354,9 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
} }
} }
/* HTTP referrer */
p_sys->psz_referrer = var_InheritString( p_access, "http-referrer" );
/* Check proxy */ /* Check proxy */
psz = var_InheritString( p_access, "http-proxy" ); psz = var_InheritString( p_access, "http-proxy" );
if( psz ) if( psz )
...@@ -596,6 +603,7 @@ connect: ...@@ -596,6 +603,7 @@ connect:
free( p_sys->psz_pragma ); free( p_sys->psz_pragma );
free( p_sys->psz_location ); free( p_sys->psz_location );
free( p_sys->psz_user_agent ); free( p_sys->psz_user_agent );
free( p_sys->psz_referrer );
Disconnect( p_access ); Disconnect( p_access );
cookies = p_sys->cookies; cookies = p_sys->cookies;
...@@ -690,6 +698,7 @@ error: ...@@ -690,6 +698,7 @@ error:
free( p_sys->psz_pragma ); free( p_sys->psz_pragma );
free( p_sys->psz_location ); free( p_sys->psz_location );
free( p_sys->psz_user_agent ); free( p_sys->psz_user_agent );
free( p_sys->psz_referrer );
Disconnect( p_access ); Disconnect( p_access );
...@@ -730,6 +739,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -730,6 +739,7 @@ static void Close( vlc_object_t *p_this )
free( p_sys->psz_icy_title ); free( p_sys->psz_icy_title );
free( p_sys->psz_user_agent ); free( p_sys->psz_user_agent );
free( p_sys->psz_referrer );
Disconnect( p_access ); Disconnect( p_access );
...@@ -1275,6 +1285,13 @@ static int Request( access_t *p_access, uint64_t i_tell ) ...@@ -1275,6 +1285,13 @@ static int Request( access_t *p_access, uint64_t i_tell )
net_Printf( p_access, p_sys->fd, pvs, net_Printf( p_access, p_sys->fd, pvs,
"User-Agent: %s\r\n", "User-Agent: %s\r\n",
p_sys->psz_user_agent ); p_sys->psz_user_agent );
/* Referrer */
if (p_sys->psz_referrer)
{
net_Printf( p_access, p_sys->fd, pvs,
"Referer: %s\r\n",
p_sys->psz_referrer);
}
/* Offset */ /* Offset */
if( p_sys->i_version == 1 && ! p_sys->b_continuous ) if( p_sys->i_version == 1 && ! p_sys->b_continuous )
{ {
......
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