From 326ec0073300ea43433586abed5cf2d4f7788e99 Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 30 May 2010 16:50:02 +0000 Subject: Add a referrer option to set the HTTP Referer field. Patch by chocolateboy [chocolate cpan org] git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31288 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/network.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'stream') diff --git a/stream/network.c b/stream/network.c index bb866318e0..8738cad113 100644 --- a/stream/network.c +++ b/stream/network.c @@ -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"); -- cgit v1.2.3