]> git.sesse.net Git - vlc/blobdiff - src/network/httpd.c
httpd: full URL is also valid for HTTP (fixes #2320)
[vlc] / src / network / httpd.c
index 2587d2deef503cb8d80511b8ec46335bedfe5be2..4dce0e8ec2f758e78c76ae8fd5c4e99018ff29dc 100644 (file)
@@ -30,8 +30,6 @@
 #include <vlc_common.h>
 #include <vlc_httpd.h>
 
-#ifdef ENABLE_HTTPD
-
 #include <assert.h>
 
 #include <vlc_network.h>
@@ -1308,7 +1306,7 @@ void httpd_UrlDelete( httpd_url_t *url )
     vlc_mutex_unlock( &host->lock );
 }
 
-void httpd_MsgInit( httpd_message_t *msg )
+static void httpd_MsgInit( httpd_message_t *msg )
 {
     msg->cl         = NULL;
     msg->i_type     = HTTPD_MSG_NONE;
@@ -1332,7 +1330,7 @@ void httpd_MsgInit( httpd_message_t *msg )
     msg->p_body        = NULL;
 }
 
-void httpd_MsgClean( httpd_message_t *msg )
+static void httpd_MsgClean( httpd_message_t *msg )
 {
     int i;
 
@@ -1745,12 +1743,16 @@ static void httpd_ClientRecv( httpd_client_t *cl )
                         {
                             *p2++ = '\0';
                         }
-                        if( !strncasecmp( p, "rtsp:", 5 ) )
-                        {
-                            /* for rtsp url, you have rtsp://localhost:port/path */
-                            p += 5;
-                            while( *p == '/' ) p++;
-                            while( *p && *p != '/' ) p++;
+                        if( !strncasecmp( p, ( cl->query.i_proto
+                                   == HTTPD_PROTO_HTTP ) ? "http" : "rtsp", 4 )
+                         && p[4 + !!strchr( "sS", p[4] )] == ':' )
+                        {   /* Skip hier-part of URL (if present) */
+                            p = strchr( p, ':' ) + 1; /* skip URI scheme */
+                            if( !strncmp( p, "//", 2 ) ) /* skip authority */
+                            {   /* see RFC3986 ยง3.2 */
+                                p += 2;
+                                while( *p && !strchr( "/?#", *p ) ) p++;
+                            }
                         }
                         cl->query.psz_url = strdup( p );
                         if( ( p3 = strchr( cl->query.psz_url, '?' ) )  )
@@ -2466,15 +2468,17 @@ retry:
         /* Handle client sockets */
         vlc_mutex_lock( &host->lock );
         now = mdate();
+        nfd = host->nfd;
         for( int i_client = 0; i_client < host->i_client; i_client++ )
         {
             httpd_client_t *cl = host->client[i_client];
-            const struct pollfd *pufd = &ufd[host->nfd + i_client];
+            const struct pollfd *pufd = &ufd[nfd];
 
             assert( pufd < &ufd[sizeof(ufd) / sizeof(ufd[0])] );
 
             if( cl->fd != pufd->fd )
                 continue; // we were not waiting for this client
+            ++nfd;
             if( pufd->revents == 0 )
                 continue; // no event received
 
@@ -2573,148 +2577,3 @@ retry:
     vlc_restorecancel (canc);
     return NULL;
 }
-
-#else /* ENABLE_HTTPD */
-
-/* We just define an empty wrapper */
-httpd_host_t *httpd_TLSHostNew( vlc_object_t *a, const char *b, 
-                                int c,
-                                const char *e, const char *f,
-                                const char *g, const char* h)
-{
-    msg_Err( a, "HTTP daemon support is disabled" );
-    return NULL;
-}
-
-httpd_host_t *httpd_HostNew( vlc_object_t *a, const char *b,
-                             int c )
-{
-    msg_Err( a, "HTTP daemon support is disabled" );
-    return NULL;
-}
-
-void httpd_HostDelete( httpd_host_t *a )
-{
-}
-
-httpd_url_t *httpd_UrlNew( httpd_host_t *host, const char *psz_url,
-                           const char *psz_user, const char *psz_password,
-                           const vlc_acl_t *p_acl )
-{
-    return NULL;
-}
-
-httpd_url_t *httpd_UrlNewUnique( httpd_host_t *host, const char *psz_url,
-                                 const char *psz_user, const char *psz_password,
-                                 const vlc_acl_t *p_acl )
-{
-    return NULL;
-}
-
-int httpd_UrlCatch( httpd_url_t *a, int b, httpd_callback_t c,
-                    httpd_callback_sys_t *d )
-{
-    return 0;
-}
-
-void httpd_UrlDelete( httpd_url_t *a )
-{
-}
-
-char* httpd_ClientIP( const httpd_client_t *cl, char *psz_ip )
-{
-    return NULL;
-}
-
-char* httpd_ServerIP( const httpd_client_t *cl, char *psz_ip )
-{
-    return NULL;
-}
-
-void httpd_ClientModeStream( httpd_client_t *a )
-{
-}
-
-void httpd_ClientModeBidir( httpd_client_t *a )
-{
-}
-
-httpd_file_sys_t *httpd_FileDelete( httpd_file_t *file )
-{
-        return NULL;
-}
-
-httpd_file_t *httpd_FileNew( httpd_host_t *host,
-                             const char *psz_url, const char *psz_mime,
-                             const char *psz_user, const char *psz_password,
-                             const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill,
-                             httpd_file_sys_t *p_sys )
-{
-    return NULL;
-}
-
-httpd_handler_t *httpd_HandlerNew( httpd_host_t *host, const char *psz_url,
-                                   const char *psz_user,
-                                   const char *psz_password,
-                                   const vlc_acl_t *p_acl,
-                                   httpd_handler_callback_t pf_fill,
-                                   httpd_handler_sys_t *p_sys )
-{
-    return NULL;
-}
-
-httpd_handler_sys_t *httpd_HandlerDelete( httpd_handler_t *handler )
-{
-        return NULL;
-}
-
-void httpd_RedirectDelete( httpd_redirect_t *a )
-{
-}
-
-httpd_redirect_t *httpd_RedirectNew( httpd_host_t *host, const char *psz_url_dst,
-                                     const char *psz_url_src )
-{
-    return NULL;
-}
-
-void httpd_StreamDelete( httpd_stream_t *a )
-{
-}
-
-int httpd_StreamHeader( httpd_stream_t *a, uint8_t *b, int c )
-{
-    return 0;
-}
-
-int httpd_StreamSend ( httpd_stream_t *a, uint8_t *b, int c )
-{
-    return 0;
-}
-
-httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
-                                 const char *psz_url, const char *psz_mime,
-                                 const char *psz_user, const char *psz_password,
-                                 const vlc_acl_t *p_acl )
-{
-    return NULL;
-}
-
-void httpd_MsgInit ( httpd_message_t *a )
-{
-}
-
-void httpd_MsgAdd  ( httpd_message_t *a, const char *b, const char *c, ... )
-{
-}
-
-const char *httpd_MsgGet( const httpd_message_t *msg, const char *name )
-{
-    return "";
-}
-
-void httpd_MsgClean( httpd_message_t *a )
-{
-}
-
-#endif /* ENABLE_HTTPD */