X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fhttp.c;h=fc62ba25ac53387065ef9b28069e9dfdce95b04b;hb=0ade81b0ebaa94d8529e4784b460bc921be70f54;hp=1f0ce83ebe9a7551abd17c895e7a162f3b985909;hpb=9e45d8e68a8f10ae7783bffd9ea27a5d5c9cf584;p=vlc diff --git a/modules/access/http.c b/modules/access/http.c index 1f0ce83ebe..fc62ba25ac 100644 --- a/modules/access/http.c +++ b/modules/access/http.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -31,9 +31,11 @@ #include #include +#include "vlc_interaction.h" #include "vlc_playlist.h" #include "vlc_meta.h" #include "network.h" +#include "vlc_url.h" #include "vlc_tls.h" /***************************************************************************** @@ -62,13 +64,15 @@ static void Close( vlc_object_t * ); "in case it was untimely closed.") #define CONTINUOUS_TEXT N_("Continuous stream") -#define CONTINUOUS_LONGTEXT N_("Enable this option to read a file that is " \ - "being constantly updated (for example, a JPG file on a server)") +#define CONTINUOUS_LONGTEXT N_("This allows you to read a file that is " \ + "being constantly updated (for example, a JPG file on a server)." \ + "You should not globally enable this option as it will break all other " \ + "types of HTTP streams." ) vlc_module_begin(); set_description( _("HTTP input") ); set_capability( "access2", 0 ); - set_shortname( _( "HTTP/HTTPS" ) ); + set_shortname( _( "HTTP(S)" ) ); set_category( CAT_INPUT ); set_subcategory( SUBCAT_INPUT_ACCESS ); @@ -77,7 +81,7 @@ vlc_module_begin(); add_integer( "http-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); add_string( "http-user-agent", COPYRIGHT_MESSAGE , NULL, AGENT_TEXT, - AGENT_LONGTEXT, VLC_FALSE ); + AGENT_LONGTEXT, VLC_TRUE ); add_bool( "http-reconnect", 0, NULL, RECONNECT_TEXT, RECONNECT_LONGTEXT, VLC_TRUE ); add_bool( "http-continuous", 0, NULL, CONTINUOUS_TEXT, @@ -187,6 +191,7 @@ static int Open( vlc_object_t *p_this ) p_sys->psz_icy_title = NULL; p_sys->i_remaining = 0; + /* Parse URI - remove spaces */ p = psz = strdup( p_access->psz_path ); while( (p = strchr( p, ' ' )) != NULL ) @@ -264,6 +269,7 @@ static int Open( vlc_object_t *p_this ) p_sys->b_reconnect = var_CreateGetBool( p_access, "http-reconnect" ); p_sys->b_continuous = var_CreateGetBool( p_access, "http-continuous" ); +connect: /* Connect */ if( Connect( p_access, 0 ) ) { @@ -277,6 +283,31 @@ static int Open( vlc_object_t *p_this ) } } + if( p_sys->i_code == 401 ) + { + char *psz_login = NULL; char *psz_password = NULL; + int i_ret; + msg_Dbg( p_access, "Authentication failed" ); + i_ret = intf_UserLoginPassword( p_access, "HTTP authentication", + "Please enter a valid login and password.", &psz_login, &psz_password ); + if( i_ret == DIALOG_OK_YES ) + { + msg_Dbg( p_access, "retrying with user=%s, pwd=%s", + psz_login, psz_password ); + if( psz_login ) p_sys->url.psz_username = strdup( psz_login ); + if( psz_password ) p_sys->url.psz_password = strdup( psz_password ); + if( psz_login ) free( psz_login ); + if( psz_password ) free( psz_password ); + goto connect; + } + else + { + if( psz_login ) free( psz_login ); + if( psz_password ) free( psz_password ); + goto error; + } + } + if( ( p_sys->i_code == 301 || p_sys->i_code == 302 || p_sys->i_code == 303 || p_sys->i_code == 307 ) && p_sys->psz_location && *p_sys->psz_location ) @@ -372,6 +403,9 @@ static int Open( vlc_object_t *p_this ) /* Grrrr! detect ultravox server and force NSV demuxer */ p_access->psz_demux = strdup( "nsv" ); } + else if( p_sys->psz_mime && + !strcasecmp( p_sys->psz_mime, "application/xspf+xml" ) ) + p_access->psz_demux = strdup( "xspf-open" ); if( p_sys->b_reconnect ) msg_Dbg( p_access, "auto re-connect enabled" ); @@ -761,7 +795,7 @@ static int Connect( access_t *p_access, int64_t i_tell ) /* Open connection */ - p_sys->fd = net_OpenTCP( p_access, srv.psz_host, srv.i_port ); + p_sys->fd = net_ConnectTCP( p_access, srv.psz_host, srv.i_port ); if( p_sys->fd < 0 ) { msg_Err( p_access, "cannot connect to %s:%d", srv.psz_host, srv.i_port ); @@ -986,7 +1020,13 @@ static int Request( access_t *p_access, int64_t i_tell ) { p_sys->b_seekable = VLC_FALSE; } - if( p_sys->i_code >= 400 ) + /* Authentication error - We'll have to display the dialog */ + if( p_sys->i_code == 401 ) + { + + } + /* Other fatal error */ + else if( p_sys->i_code >= 400 ) { msg_Err( p_access, "error: %s", psz ); free( psz );