mirror of
https://github.com/mpv-player/mpv
synced 2025-06-06 14:17:44 +02:00
Fix lots of bugs in mp_http URL handling
Many instances of "http" were not changed to "mp_http", which made many aspects of the mp_http protocol handler broken.
This commit is contained in:
parent
7c40d8a36e
commit
944be9d24b
14
core/quvi.c
14
core/quvi.c
@ -26,12 +26,18 @@
|
|||||||
struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts)
|
struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts)
|
||||||
{
|
{
|
||||||
QUVIcode rc;
|
QUVIcode rc;
|
||||||
|
bool mp_url = false;
|
||||||
|
|
||||||
quvi_t q;
|
quvi_t q;
|
||||||
rc = quvi_init(&q);
|
rc = quvi_init(&q);
|
||||||
if (rc != QUVI_OK)
|
if (rc != QUVI_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (!strncmp(url, "mp_", 3)) {
|
||||||
|
url += 3;
|
||||||
|
mp_url = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Don't try to use quvi on an URL that's not directly supported, since
|
// Don't try to use quvi on an URL that's not directly supported, since
|
||||||
// quvi will do a network access anyway in order to check for HTTP
|
// quvi will do a network access anyway in order to check for HTTP
|
||||||
// redirections etc.
|
// redirections etc.
|
||||||
@ -65,8 +71,12 @@ struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts)
|
|||||||
|
|
||||||
char *val;
|
char *val;
|
||||||
|
|
||||||
if (quvi_getprop(m, QUVIPROP_MEDIAURL, &val) == QUVI_OK)
|
if (quvi_getprop(m, QUVIPROP_MEDIAURL, &val) == QUVI_OK) {
|
||||||
result->url = talloc_strdup(result, val);
|
if (mp_url)
|
||||||
|
result->url = talloc_asprintf(result, "mp_%s", val);
|
||||||
|
else
|
||||||
|
result->url = talloc_strdup(result, val);
|
||||||
|
}
|
||||||
|
|
||||||
if (quvi_getprop(m, QUVIPROP_PAGETITLE, &val) == QUVI_OK)
|
if (quvi_getprop(m, QUVIPROP_PAGETITLE, &val) == QUVI_OK)
|
||||||
result->title = talloc_strdup(result, val);
|
result->title = talloc_strdup(result, val);
|
||||||
|
@ -110,12 +110,12 @@ check4proxies( const URL_t *url ) {
|
|||||||
URL_t *url_out = NULL;
|
URL_t *url_out = NULL;
|
||||||
if( url==NULL ) return NULL;
|
if( url==NULL ) return NULL;
|
||||||
url_out = url_new( url->url );
|
url_out = url_new( url->url );
|
||||||
if( !strcasecmp(url->protocol, "http_proxy") ) {
|
if( !strcasecmp(url->protocol, "mp_http_proxy") ) {
|
||||||
mp_msg(MSGT_NETWORK,MSGL_V,"Using HTTP proxy: http://%s:%d\n", url->hostname, url->port );
|
mp_msg(MSGT_NETWORK,MSGL_V,"Using HTTP proxy: http://%s:%d\n", url->hostname, url->port );
|
||||||
return url_out;
|
return url_out;
|
||||||
}
|
}
|
||||||
// Check if the http_proxy environment variable is set.
|
// Check if the http_proxy environment variable is set.
|
||||||
if( !strcasecmp(url->protocol, "http") ) {
|
if( !strcasecmp(url->protocol, "mp_http") ) {
|
||||||
char *proxy;
|
char *proxy;
|
||||||
proxy = getenv("http_proxy");
|
proxy = getenv("http_proxy");
|
||||||
if( proxy!=NULL ) {
|
if( proxy!=NULL ) {
|
||||||
@ -180,9 +180,12 @@ http_send_request( URL_t *url, int64_t pos ) {
|
|||||||
|
|
||||||
http_hdr = http_new_header();
|
http_hdr = http_new_header();
|
||||||
|
|
||||||
if( !strcasecmp(url->protocol, "http_proxy") ) {
|
if( !strcasecmp(url->protocol, "mp_http_proxy") ) {
|
||||||
proxy = 1;
|
proxy = 1;
|
||||||
server_url = url_new( (url->file)+1 );
|
if (!strncasecmp(url->file, "/mp_", 3))
|
||||||
|
server_url = url_new( (url->file)+4 );
|
||||||
|
else
|
||||||
|
server_url = url_new( (url->file)+1 );
|
||||||
if (!server_url) {
|
if (!server_url) {
|
||||||
mp_msg(MSGT_NETWORK, MSGL_ERR, "Invalid URL '%s' to proxify\n", url->file+1);
|
mp_msg(MSGT_NETWORK, MSGL_ERR, "Invalid URL '%s' to proxify\n", url->file+1);
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
@ -61,7 +61,7 @@ end:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int is_proxy(const URL_t *url) {
|
static int is_proxy(const URL_t *url) {
|
||||||
return !strcasecmp(url->protocol, "http_proxy") && url->file && strstr(url->file, "://");
|
return !strcasecmp(url->protocol, "mp_http_proxy") && url->file && strstr(url->file, "://");
|
||||||
}
|
}
|
||||||
|
|
||||||
int url_is_protocol(const URL_t *url, const char *proto) {
|
int url_is_protocol(const URL_t *url, const char *proto) {
|
||||||
@ -137,12 +137,12 @@ static char *get_noauth_url(const URL_t *url)
|
|||||||
char *get_http_proxy_url(const URL_t *proxy, const char *host_url)
|
char *get_http_proxy_url(const URL_t *proxy, const char *host_url)
|
||||||
{
|
{
|
||||||
if (proxy->username)
|
if (proxy->username)
|
||||||
return mp_asprintf("http_proxy://%s:%s@%s:%d/%s",
|
return mp_asprintf("mp_http_proxy://%s:%s@%s:%d/%s",
|
||||||
proxy->username,
|
proxy->username,
|
||||||
proxy->password ? proxy->password : "",
|
proxy->password ? proxy->password : "",
|
||||||
proxy->hostname, proxy->port, host_url);
|
proxy->hostname, proxy->port, host_url);
|
||||||
else
|
else
|
||||||
return mp_asprintf("http_proxy://%s:%d/%s",
|
return mp_asprintf("mp_http_proxy://%s:%d/%s",
|
||||||
proxy->hostname, proxy->port, host_url);
|
proxy->hostname, proxy->port, host_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user