diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-05-30 16:50:02 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-05-30 16:50:02 +0000 |
commit | 326ec0073300ea43433586abed5cf2d4f7788e99 (patch) | |
tree | 6bf21722f58acfd29960a6b8b6541cbfd4f21937 | |
parent | a8dab8b5216e6367c66d4ba468625e849521b50a (diff) |
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
-rw-r--r-- | DOCS/man/en/mplayer.1 | 4 | ||||
-rw-r--r-- | cfg-common-opts.h | 1 | ||||
-rw-r--r-- | cfg-common.h | 1 | ||||
-rw-r--r-- | stream/network.c | 18 |
4 files changed, 24 insertions, 0 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 9c5d7af513..11f5c9685d 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -1789,6 +1789,10 @@ Play a raw YUV sample. .PD 1 . .TP +.B \-referrer <string> (network only) +Specify a referrer path or URL for HTTP requests. +. +.TP .B \-rtsp\-port Used with 'rtsp://' URLs to force the client's port number. This option may be useful if you are behind a router and want to forward diff --git a/cfg-common-opts.h b/cfg-common-opts.h index dbaee846c9..b701ba26e5 100644 --- a/cfg-common-opts.h +++ b/cfg-common-opts.h @@ -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}, diff --git a/cfg-common.h b/cfg-common.h index 002d3ca528..9ad236abaf 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -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; 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"); |