[vlc-devel] [PATCH] This patch adds an --http-add-head-string (additional header string) option to vlc

Maximilian Podany m.podany at art-est.at
Sun Aug 1 20:57:04 CEST 2010


You could use it to add an arbitrary string to the
HTTP-GET-request-header. For example a referer string like "Referer:
http://www.example.com".
 
 I noticed that if I use a vlc-firefox-plugin to play divx-streams it
doesn't work on some servers.
 After some research (wireshark and telnet ;-) I noticed that the
divx-webplayer sends an referer string in the HTTP-GET-request-header
and without the referer the server responds with "Moved Permanently".
 So with this option you could use vlc to spoof a divx-webplayer (with
user-agent changes).
 But because you can define the whole header-line with this option, you
could add every string you like.

---
 modules/access/http.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/modules/access/http.c b/modules/access/http.c
index 398c38b..2260058 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -86,6 +86,10 @@ static void Close( vlc_object_t * );
 #define AGENT_TEXT N_("HTTP user agent")
 #define AGENT_LONGTEXT N_("User agent that will be " \
     "used for the connection.")
+    
+#define ADDHEAD_TEXT N_("Additional HTTP-header-string")
+#define ADDHEAD_LONGTEXT N_("Arbitrary string which " \
+    "will be added to the http-header of a GET request (e.g.
referer)")    
 
 #define RECONNECT_TEXT N_("Auto re-connect")
 #define RECONNECT_LONGTEXT N_( \
@@ -126,6 +130,9 @@ vlc_module_begin ()
     add_string( "http-user-agent", PACKAGE_NAME"/"PACKAGE_VERSION,
NULL,
                 AGENT_TEXT, AGENT_LONGTEXT, true )
         change_safe()
+    add_string( "http-add-head-string", PACKAGE_NAME"/"PACKAGE_VERSION,
NULL,
+                ADDHEAD_TEXT, ADDHEAD_LONGTEXT, true )
+        change_safe()	
         change_need_restart()
     add_bool( "http-reconnect", false, NULL, RECONNECT_TEXT,
               RECONNECT_LONGTEXT, true )
@@ -161,6 +168,7 @@ struct access_sys_t
     /* From uri */
     vlc_url_t url;
     char    *psz_user_agent;
+    char    *psz_add_head_string;	
     http_auth_t auth;
 
     /* Proxy */
@@ -286,6 +294,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_add_head_string = NULL;
     p_sys->b_pace_control = true;
     p_sys->b_ssl = false;
 #ifdef HAVE_ZLIB_H
@@ -352,6 +361,10 @@ static int OpenWithCookies( vlc_object_t *p_this,
const char *psz_access,
             *p = '_'; /* remove potentially harmful characters */
     }
 
+    /* Add additional string to the HTTP-GET-request-header. */
+    /* e.g. a referer string */
+    p_sys->psz_add_head_string = var_InheritString( p_access,
"http-add-head-string" );
+    
     /* Check proxy */
     psz = var_InheritString( p_access, "http-proxy" );
     if( psz )
@@ -598,6 +611,7 @@ connect:
         free( p_sys->psz_pragma );
         free( p_sys->psz_location );
         free( p_sys->psz_user_agent );
+	free( p_sys->psz_add_head_string );
 
         Disconnect( p_access );
         cookies = p_sys->cookies;
@@ -692,6 +706,7 @@ error:
     free( p_sys->psz_pragma );
     free( p_sys->psz_location );
     free( p_sys->psz_user_agent );
+    free( p_sys->psz_add_head_string );
 
     Disconnect( p_access );
 
@@ -732,6 +747,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_add_head_string );	
 
     Disconnect( p_access );
 
@@ -1287,6 +1303,10 @@ 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 );
+     /* Additional HTTP-GET-request-header-string*/
+    net_Printf( p_access, p_sys->fd, pvs,
+                "%s\r\n",
+                p_sys->psz_add_head_string );
     /* Offset */
     if( p_sys->i_version == 1 && ! p_sys->b_continuous )
     {
-- 
1.6.3.3




More information about the vlc-devel mailing list