stream: http: Allow setting custom http header

Patch by Nikolay Nikolaev, nicknickolaev yahoo com

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33082 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
cehoyos 2011-03-17 08:58:49 +00:00 committed by Uoti Urpala
parent 4b5a86c78e
commit c99d8fc898
4 changed files with 39 additions and 0 deletions

View File

@ -1485,6 +1485,35 @@ Can be slow especially when seeking backwards since it has to rewind
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.

View File

@ -425,6 +425,7 @@ const m_option_t common_opts[] = {
{"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},

View File

@ -58,6 +58,7 @@ int network_bandwidth=0;
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;
@ -250,6 +251,12 @@ http_send_request( URL_t *url, off_t pos ) {
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);

View File

@ -61,6 +61,8 @@ typedef struct {
extern const mime_struct_t mime_type_table[];
extern char **network_http_header_fields;
streaming_ctrl_t *streaming_ctrl_new(void);
int streaming_bufferize( streaming_ctrl_t *streaming_ctrl, char *buffer, int size);