X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fhttp.c;h=29da639b21826d1c9b37236c8260a7e98fd4da8f;hb=726e4ea7f61c9a54675f879ca450d7753f6d848c;hp=8f5cfbcc77645d442de9d658023bc71054708446;hpb=002135d9e4de26b5ed725739b4ad7c03b7b5dda2;p=vlc diff --git a/modules/access/http.c b/modules/access/http.c index 8f5cfbcc77..29da639b21 100644 --- a/modules/access/http.c +++ b/modules/access/http.c @@ -123,9 +123,10 @@ vlc_module_begin () add_integer( "http-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, true ) change_safe() - add_string( "http-user-agent", PACKAGE_NAME" "PACKAGE_VERSION, NULL, + add_string( "http-user-agent", PACKAGE_NAME"/"PACKAGE_VERSION, NULL, AGENT_TEXT, AGENT_LONGTEXT, true ) change_safe() + change_need_restart() add_bool( "http-reconnect", false, NULL, RECONNECT_TEXT, RECONNECT_LONGTEXT, true ) add_bool( "http-continuous", false, NULL, CONTINUOUS_TEXT, @@ -141,11 +142,8 @@ vlc_module_begin () #endif add_obsolete_string("http-user") add_obsolete_string("http-pwd") - add_shortcut( "http" ) - add_shortcut( "https" ) - add_shortcut( "unsv" ) - add_shortcut( "itpc" ) /* iTunes Podcast */ - add_shortcut( "icyx" ) + /* 'itpc' = iTunes Podcast */ + add_shortcut( "http", "https", "unsv", "itpc", "icyx" ) set_callbacks( Open, Close ) vlc_module_end () @@ -344,8 +342,15 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access, p_sys->url.i_port = 80; } - /* Do user agent */ + /* Determine the HTTP user agent */ + /* See RFC2616 §2.2 token definition and §3.8 user-agent header */ p_sys->psz_user_agent = var_InheritString( p_access, "http-user-agent" ); + for( char *p = p_sys->psz_user_agent; *p; p++ ) + { + uint8_t c = *p; + if( c < 32 || strchr( "()<>@,;:\\\"[]?={}", c ) ) + *p = '_'; /* remove potentially harmful characters */ + } /* Check proxy */ psz = var_InheritString( p_access, "http-proxy" ); @@ -419,7 +424,7 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access, { /* Get the proxy URL : Proxy server value in the registry can be something like "address:port" - or "ftp=adress1:port1;http=adress2:port2 ..." depending of the + or "ftp=address1:port1;http=address2:port2 ..." depending of the confirguration. */ char *psz_proxy; psz_proxy = strstr( psz_key, "http=" ); @@ -1069,7 +1074,7 @@ static int Control( access_t *p_access, int i_query, va_list args ) /* */ case ACCESS_GET_PTS_DELAY: pi_64 = (int64_t*)va_arg( args, int64_t * ); - *pi_64 = (int64_t)var_GetInteger( p_access, "http-caching" ) * 1000; + *pi_64 = var_GetInteger( p_access, "http-caching" ) * 1000; break; /* */ @@ -1279,7 +1284,8 @@ static int Request( access_t *p_access, uint64_t i_tell ) } } /* User Agent */ - net_Printf( p_access, p_sys->fd, pvs, "User-Agent: %s\r\n", + net_Printf( p_access, p_sys->fd, pvs, + "User-Agent: %s LibVLC/"VERSION"\r\n", p_sys->psz_user_agent ); /* Offset */ if( p_sys->i_version == 1 && ! p_sys->b_continuous )