Mercurial > mplayer.hg
changeset 32995:80e4a267f6b8
Allow setting custom http header.
Patch by Nikolay Nikolaev, nicknickolaev yahoo com
author | cehoyos |
---|---|
date | Thu, 17 Mar 2011 08:58:49 +0000 |
parents | eba7d1dc92a6 |
children | 4aeda8386f66 |
files | DOCS/man/en/mplayer.1 cfg-common.h stream/network.c stream/network.h |
diffstat | 4 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Mon Mar 14 00:07:11 2011 +0000 +++ b/DOCS/man/en/mplayer.1 Thu Mar 17 08:58:49 2011 +0000 @@ -1575,6 +1575,35 @@ to the beginning to find an exact frame position. . .TP +.B \-http-header-fields <field1,field2> +Set custom HTTP fields when accessing HTTP stream. +.sp 1 +.I EXAMPLE: +.PD 0 +.RSs +.IPs +mplayer \-http\-header\-fields 'Field1: value1','Field2: value2' http://localhost:1234 +.br +Will generate HTTP request: +.RSss +.br +GET / HTTP/1.0 +.br +Host: localhost:1234 +.br +User-Agent: MPlayer +.br +Icy-MetaData: 1 +.br +Field1: value1 +.br +Field2: value2 +.br +Connection: close +.REss +.RE +. +.TP .B \-idx (also see \-forceidx) Rebuilds index of files if no index was found, allowing seeking. Useful with broken/\:incomplete downloads, or badly created files.
--- a/cfg-common.h Mon Mar 14 00:07:11 2011 +0000 +++ b/cfg-common.h Thu Mar 17 08:58:49 2011 +0000 @@ -354,6 +354,7 @@ {"user", &network_username, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"passwd", &network_password, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"bandwidth", &network_bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, + {"http-header-fields", &network_http_header_fields, CONF_TYPE_STRING_LIST, 0, 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},
--- a/stream/network.c Mon Mar 14 00:07:11 2011 +0000 +++ b/stream/network.c Thu Mar 17 08:58:49 2011 +0000 @@ -57,6 +57,7 @@ int network_cookies_enabled = 0; char *network_useragent=NULL; char *network_referrer=NULL; +char **network_http_header_fields=NULL; /* IPv6 options */ int network_ipv4_only_proxy = 0; @@ -246,6 +247,12 @@ if (network_cookies_enabled) cookies_set( http_hdr, server_url->hostname, server_url->url ); + if (network_http_header_fields) { + int i=0; + while (network_http_header_fields[i]) + http_set_field(http_hdr, network_http_header_fields[i++]); + } + http_set_field( http_hdr, "Connection: close"); if (proxy) http_add_basic_proxy_authentication(http_hdr, url->username, url->password);
--- a/stream/network.h Mon Mar 14 00:07:11 2011 +0000 +++ b/stream/network.h Thu Mar 17 08:58:49 2011 +0000 @@ -66,6 +66,7 @@ extern char *network_referrer; extern char *network_useragent; extern char *network_username; +extern char **network_http_header_fields; extern int network_bandwidth; extern int network_cookies_enabled;