[vlc-commits] httpd: URL-parse --http-host and --rtsp-host
Pierre Ynard
git at videolan.org
Sun Dec 18 19:38:01 CET 2011
vlc/vlc-1.2 | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Dec 18 18:58:23 2011 +0100| [774c98758bd0a09c006fcb1bc7951d20d6c50c66] | committer: 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
(cherry picked from commit 37eb636261b66b1a8d5cff1b247096a946ff4f65)
Signed-off-by: Pierre Ynard <linkfanel at yahoo.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=774c98758bd0a09c006fcb1bc7951d20d6c50c66
---
src/network/httpd.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/network/httpd.c b/src/network/httpd.c
index 30bce23..e90cc40 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -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;
@@ -1073,9 +1086,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" );
@@ -1108,6 +1119,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:
@@ -1121,6 +1134,8 @@ error:
vlc_object_release( host );
}
+ vlc_UrlClean( &url );
+
if( p_tls != NULL )
vlc_tls_ServerDelete( p_tls );
More information about the vlc-commits
mailing list