mirror of https://github.com/mpv-player/mpv
User settable http user-agent. Patch by Per Wigren
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11229 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
400850c793
commit
2d0a6214d3
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue