[vlc-devel] [PATCH] Add http-referrer option to HTTP access module
Jonas Gehring
jonas.gehring at boolsoft.org
Fri Nov 12 23:51:08 CET 2010
Kaarlo Räihä <kaarlo.raiha at gmail.com> wrote:
> I think J-B means that it should look something like:
> add_integer( "http-caching", 4 * DEFAULT_PTS_DELAY / 1000, CACHING_TEXT,
> CACHING_LONGTEXT, true )
> change_safe()
> add_string( "http-referrer", NULL, NULL, NULL, false )
> change_safe()
> add_string( "http-user-agent", NULL, NULL, NULL, false )
> change_safe()
>
> So your current patch turns http-caching non-safe since the http-referrer is
> inserted between two connected elements.
I see, the change_*() macros affect the previous option. I've changed
the option declaration according to your suggestion (patch attached).
Regards,
Jonas
-------------- next part --------------
>From 9c750bbae66734907d443b004d4fa8f8e3ed4a94 Mon Sep 17 00:00:00 2001
From: Jonas Gehring <jonas.gehring at boolsoft.org>
Date: Fri, 12 Nov 2010 23:49:17 +0100
Subject: [PATCH] Add http-referrer option to HTTP access module
---
modules/access/http.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/modules/access/http.c b/modules/access/http.c
index e4ea721..ee86525 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -119,6 +119,8 @@ vlc_module_begin ()
add_integer( "http-caching", 4 * DEFAULT_PTS_DELAY / 1000,
CACHING_TEXT, CACHING_LONGTEXT, true )
change_safe()
+ add_string( "http-referrer", NULL, NULL, NULL, false )
+ change_safe()
add_string( "http-user-agent", NULL, NULL, NULL, false )
change_safe()
change_private()
@@ -156,6 +158,7 @@ struct access_sys_t
/* From uri */
vlc_url_t url;
char *psz_user_agent;
+ char *psz_referrer;
http_auth_t auth;
/* Proxy */
@@ -281,6 +284,7 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
p_sys->b_icecast = false;
p_sys->psz_location = NULL;
p_sys->psz_user_agent = NULL;
+ p_sys->psz_referrer = NULL;
p_sys->b_pace_control = true;
p_sys->b_ssl = false;
#ifdef HAVE_ZLIB_H
@@ -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 */
psz = var_InheritString( p_access, "http-proxy" );
if( psz )
@@ -596,6 +603,7 @@ connect:
free( p_sys->psz_pragma );
free( p_sys->psz_location );
free( p_sys->psz_user_agent );
+ free( p_sys->psz_referrer );
Disconnect( p_access );
cookies = p_sys->cookies;
@@ -690,6 +698,7 @@ error:
free( p_sys->psz_pragma );
free( p_sys->psz_location );
free( p_sys->psz_user_agent );
+ free( p_sys->psz_referrer );
Disconnect( p_access );
@@ -730,6 +739,7 @@ static void Close( vlc_object_t *p_this )
free( p_sys->psz_icy_title );
free( p_sys->psz_user_agent );
+ free( p_sys->psz_referrer );
Disconnect( p_access );
@@ -1285,6 +1295,13 @@ static int Request( access_t *p_access, uint64_t i_tell )
net_Printf( p_access, p_sys->fd, pvs,
"User-Agent: %s\r\n",
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 */
if( p_sys->i_version == 1 && ! p_sys->b_continuous )
{
--
1.5.6.5
More information about the vlc-devel
mailing list