summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/mplayer.13
-rw-r--r--cfg-common.h4
-rw-r--r--libmpdemux/network.c16
3 files changed, 19 insertions, 4 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index 4268bee7a9..568a9c7d21 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -824,6 +824,9 @@ demuxer selection.
.B \-passwd <password> (see \-user option too)
Specify password for http authentication.
.TP
+.B \-user-agent <string>
+Use string as User-Agent for HTTP streaming.
+.TP
.B \-prefer-ipv4
Use IPv4 on network connections.
Falls back to IPv6 automatically.
diff --git a/cfg-common.h b/cfg-common.h
index c48f86d9ed..6dd9cfdb83 100644
--- a/cfg-common.h
+++ b/cfg-common.h
@@ -41,6 +41,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},
+ {"user-agent", &network_useragent, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"prefer-ipv4", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"ipv4-only-proxy", &network_ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, NULL},
@@ -53,7 +54,9 @@
#else
{"user", "MPlayer was compiled WITHOUT streaming(network) support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+ {"passwd", "MPlayer was compiled WITHOUT streaming(network) support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
{"bandwidth", "MPlayer was compiled WITHOUT streaming(network) support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+ {"user-agent", "MPlayer was compiled WITHOUT streaming(network) support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
#endif
@@ -273,6 +276,7 @@ extern int audio_output_channels;
extern char *network_username;
extern char *network_password;
extern int network_bandwidth;
+extern char *network_useragent;
extern int network_prefer_ipv4;
extern int network_ipv4_only_proxy;
diff --git a/libmpdemux/network.c b/libmpdemux/network.c
index ac0e2c70dc..d858c3bd0f 100644
--- a/libmpdemux/network.c
+++ b/libmpdemux/network.c
@@ -47,10 +47,12 @@ extern int mp_input_check_interrupt(int time);
int asf_streaming_start( stream_t *stream, int *demuxer_type );
int rtsp_streaming_start( stream_t *stream );
-/* Variables for the command line option -user, -passwd & -bandwidth */
+/* Variables for the command line option -user, -passwd, -bandwidth
+ and -user-agent */
char *network_username=NULL;
char *network_password=NULL;
int network_bandwidth=0;
+char *network_useragent=NULL;
/* IPv6 options */
int network_prefer_ipv4 = 0;
@@ -426,7 +428,7 @@ int
http_send_request( URL_t *url ) {
HTTP_header_t *http_hdr;
URL_t *server_url;
- char str[80];
+ char str[256];
int fd;
int ret;
int proxy = 0; // Boolean
@@ -441,9 +443,15 @@ http_send_request( URL_t *url ) {
server_url = url;
http_set_uri( http_hdr, server_url->file );
}
- snprintf(str, 80, "Host: %s", server_url->hostname );
+ snprintf(str, 256, "Host: %s", server_url->hostname );
http_set_field( http_hdr, str);
- http_set_field( http_hdr, "User-Agent: MPlayer/"VERSION);
+ if (network_useragent)
+ {
+ snprintf(str, 256, "User-Agent: %s", network_useragent);
+ http_set_field(http_hdr, str);
+ }
+ else
+ http_set_field( http_hdr, "User-Agent: MPlayer/"VERSION);
http_set_field( http_hdr, "Connection: closed");
http_add_basic_authentication( http_hdr, url->username, url->password );
if( http_build_request( http_hdr )==NULL ) {