changeset 11228:f25d54466044

User settable http user-agent. Patch by Per Wigren
author alex
date Wed, 22 Oct 2003 17:54:32 +0000
parents a7cbee9f21f7
children b4040706e1d3
files DOCS/man/en/mplayer.1 cfg-common.h libmpdemux/network.c
diffstat 3 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Wed Oct 22 17:36:47 2003 +0000
+++ b/DOCS/man/en/mplayer.1	Wed Oct 22 17:54:32 2003 +0000
@@ -824,6 +824,9 @@
 .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.
--- a/cfg-common.h	Wed Oct 22 17:36:47 2003 +0000
+++ b/cfg-common.h	Wed Oct 22 17:54:32 2003 +0000
@@ -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 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;
--- a/libmpdemux/network.c	Wed Oct 22 17:36:47 2003 +0000
+++ b/libmpdemux/network.c	Wed Oct 22 17:54:32 2003 +0000
@@ -47,10 +47,12 @@
 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 @@
 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 @@
 		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 ) {