Commit 37eb6362 authored by Pierre Ynard's avatar Pierre Ynard

httpd: URL-parse --http-host and --rtsp-host

This deals gracefully with and warns about the legacy
--http-host <host>:<port> and --rtsp-host <host>:<port>/<path> syntaxes
parent 7be3c8c3
......@@ -38,6 +38,7 @@
#include <vlc_strings.h>
#include <vlc_rand.h>
#include <vlc_charset.h>
#include <vlc_url.h>
#include "../libvlc.h"
#include <string.h>
......@@ -1032,8 +1033,19 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
vlc_tls_creds_t *p_tls )
{
httpd_host_t *host;
char *hostname = var_InheritString( p_this, hostvar );
unsigned port = var_InheritInteger( p_this, portvar );
vlc_url_t url;
vlc_UrlParse( &url, hostname, 0 );
free( hostname );
if( url.i_port != 0 )
{
msg_Err( p_this, "Ignoring port %d (using %d)", url.i_port, port );
msg_Info( p_this, "Specify port %d separately with the "
"%s option instead.", url.i_port, portvar );
}
/* to be sure to avoid multiple creation */
vlc_mutex_lock( &httpd.mutex );
......@@ -1056,6 +1068,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
vlc_mutex_unlock( &host->lock );
vlc_mutex_unlock( &httpd.mutex );
vlc_UrlClean( &url );
if( p_tls != NULL )
vlc_tls_ServerDelete( p_tls );
return host;
......@@ -1071,9 +1084,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
vlc_cond_init( &host->wait );
host->i_ref = 1;
char *hostname = var_InheritString( p_this, hostvar );
host->fds = net_ListenTCP( p_this, hostname, port );
free( hostname );
host->fds = net_ListenTCP( p_this, url.psz_host, port );
if( host->fds == NULL )
{
msg_Err( p_this, "cannot create socket(s) for HTTP host" );
......@@ -1106,6 +1117,8 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
TAB_APPEND( httpd.i_host, httpd.host, host );
vlc_mutex_unlock( &httpd.mutex );
vlc_UrlClean( &url );
return host;
error:
......@@ -1119,6 +1132,8 @@ error:
vlc_object_release( host );
}
vlc_UrlClean( &url );
if( p_tls != NULL )
vlc_tls_ServerDelete( p_tls );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment