]> git.sesse.net Git - vlc/blobdiff - src/network/httpd.c
Fix Server: HTTP and RTSP header syntax
[vlc] / src / network / httpd.c
index 39835a20c3620a4e8f2bb7c6052b6a52adf8578d..2e95eedc38ffd0d352de06c6e87bc50101db38dc 100644 (file)
@@ -36,6 +36,7 @@
 #include <vlc_tls.h>
 #include <vlc_acl.h>
 #include <vlc_strings.h>
+#include <vlc_rand.h>
 #include "../libvlc.h"
 
 #include <string.h>
@@ -825,7 +826,8 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
                           "application/octet-stream" );
             httpd_MsgAdd( answer, "Server", "Cougar 4.1.0.3921" );
             httpd_MsgAdd( answer, "Pragma", "no-cache" );
-            httpd_MsgAdd( answer, "Pragma", "client-id=%d", rand()&0x7fff );
+            httpd_MsgAdd( answer, "Pragma", "client-id=%lu",
+                          vlc_mrand48()&0x7fff );
             httpd_MsgAdd( answer, "Pragma", "features=\"broadcast\"" );
 
             /* Check if there is a xPlayStrm=1 */
@@ -1079,6 +1081,8 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
     vlc_cond_init( &host->wait );
     host->i_ref = 1;
 
+    vlc_object_attach( host, p_this );
+
     host->fds = net_ListenTCP( p_this, psz_host, i_port );
     if( host->fds == NULL )
     {
@@ -2140,7 +2144,7 @@ static void* httpd_HostThread( void *data )
                     answer->i_body = 0;
                     answer->p_body = NULL;
 
-                    httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
+                    httpd_MsgAdd( answer, "Server", "VLC/%s", VERSION );
                     httpd_MsgAdd( answer, "Content-Length", "0" );
 
                     switch( query->i_proto )
@@ -2511,15 +2515,12 @@ static void* httpd_HostThread( void *data )
                 continue;
 
             /* */
-#ifdef HAVE_ACCEPT4
-            fd = accept4 (fd, NULL, NULL, SOCK_CLOEXEC);
-            if (fd == -1 && errno == ENOSYS)
-#endif
-            fd = accept (fd, NULL, NULL);
+            fd = vlc_accept (fd, NULL, NULL, true);
             if (fd == -1)
                 continue;
+            setsockopt (fd, SOL_SOCKET, SO_REUSEADDR,
+                        &(int){ 1 }, sizeof(int));
 
-            net_SetupSocket (fd);
             if( p_tls != NULL )
             {
                 switch( tls_ServerSessionHandshake( p_tls, fd ) )