[MPlayer-cvslog] r31288 - in trunk: DOCS/man/en/mplayer.1 cfg-common-opts.h cfg-common.h stream/network.c
reimar
subversion at mplayerhq.hu
Sun May 30 18:50:02 CEST 2010
Author: reimar
Date: Sun May 30 18:50:02 2010
New Revision: 31288
Log:
Add a referrer option to set the HTTP Referer field.
Patch by chocolateboy [chocolate cpan org]
Modified:
trunk/cfg-common-opts.h
trunk/cfg-common.h
trunk/stream/network.c
Changes in other areas also in this revision:
Modified:
trunk/DOCS/man/en/mplayer.1
Modified: trunk/cfg-common-opts.h
==============================================================================
--- trunk/cfg-common-opts.h Sun May 30 18:48:18 2010 (r31287)
+++ trunk/cfg-common-opts.h Sun May 30 18:50:02 2010 (r31288)
@@ -78,6 +78,7 @@
{"passwd", &network_password, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"bandwidth", &network_bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
{"user-agent", &network_useragent, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"referrer", &network_referrer, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"cookies", &network_cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"nocookies", &network_cookies_enabled, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"cookies-file", &cookies_file, CONF_TYPE_STRING, 0, 0, 0, NULL},
Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h Sun May 30 18:48:18 2010 (r31287)
+++ trunk/cfg-common.h Sun May 30 18:50:02 2010 (r31288)
@@ -47,6 +47,7 @@ extern char *network_username;
extern char *network_password;
extern int network_bandwidth;
extern char *network_useragent;
+extern char *network_referrer;
extern int network_cookies_enabled;
extern char *cookies_file;
Modified: trunk/stream/network.c
==============================================================================
--- trunk/stream/network.c Sun May 30 18:48:18 2010 (r31287)
+++ trunk/stream/network.c Sun May 30 18:50:02 2010 (r31288)
@@ -62,6 +62,7 @@ char *network_password=NULL;
int network_bandwidth=0;
int network_cookies_enabled = 0;
char *network_useragent=NULL;
+char *network_referrer=NULL;
/* IPv6 options */
int network_ipv4_only_proxy = 0;
@@ -226,6 +227,23 @@ http_send_request( URL_t *url, off_t pos
else
http_set_field( http_hdr, "User-Agent: MPlayer/"VERSION);
+ if (network_referrer) {
+ char *referrer = NULL;
+ size_t len = strlen(network_referrer) + 10;
+
+ // Check len to ensure we don't do something really bad in case of an overflow
+ if (len > 10)
+ referrer = malloc(len);
+
+ if (referrer == NULL) {
+ mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MemAllocFailed);
+ } else {
+ snprintf(referrer, len, "Referer: %s", network_referrer);
+ http_set_field(http_hdr, referrer);
+ free(referrer);
+ }
+ }
+
if( strcasecmp(url->protocol, "noicyx") )
http_set_field(http_hdr, "Icy-MetaData: 1");
More information about the MPlayer-cvslog
mailing list