Fix Require header support
authorRémi Denis-Courmont <rem@videolan.org>
Wed, 22 Aug 2007 19:49:44 +0000 (19:49 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Wed, 22 Aug 2007 19:49:44 +0000 (19:49 +0000)
modules/stream_out/rtp.c
src/network/httpd.c

index 6959ad6..91609e9 100644 (file)
@@ -1643,7 +1643,11 @@ static int  RtspCallback( httpd_callback_sys_t *p_args,
     answer->p_body = NULL;
 
     if( httpd_MsgGet( query, "Require" ) != NULL )
+    {
         answer->i_status = 551;
+        httpd_MsgAdd( query, "Unsupported", "%s",
+                      httpd_MsgGet( query, "Require" ) );
+    }
     else
     switch( query->i_type )
     {
@@ -1745,10 +1749,11 @@ static int  RtspCallback( httpd_callback_sys_t *p_args,
             return VLC_EGENERIC;
     }
 
-    httpd_MsgAdd( answer, "Server", PACKAGE_STRING );
+    httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
     httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
     psz_cseq = httpd_MsgGet( query, "Cseq" );
-    httpd_MsgAdd( answer, "Cseq", "%s", psz_cseq ? psz_cseq : "0" );
+    if( psz_cseq )
+        httpd_MsgAdd( answer, "Cseq", "%s", psz_cseq );
     httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
 
     if( psz_session )
@@ -1815,7 +1820,11 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
     }
 
     if( httpd_MsgGet( query, "Require" ) != NULL )
+    {
         answer->i_status = 551;
+        httpd_MsgAdd( query, "Unsupported", "%s",
+                      httpd_MsgGet( query, "Require" ) );
+    }
     else
     switch( query->i_type )
     {
@@ -1993,14 +2002,13 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
         default:
             answer->i_status = 460;
             break;
-
-            return VLC_EGENERIC;
     }
 
-    httpd_MsgAdd( answer, "Server", PACKAGE_STRING );
-    httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
     psz_cseq = httpd_MsgGet( query, "Cseq" );
-    httpd_MsgAdd( answer, "Cseq", "%s", psz_cseq ? psz_cseq : "0");
+    if( psz_cseq )
+        httpd_MsgAdd( answer, "Cseq", "%s", psz_cseq );
+    httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
+    httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
     httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
 
     if( psz_session )
index 47d8ad9..67acd88 100644 (file)
@@ -2036,24 +2036,28 @@ static void httpd_HostThread( httpd_host_t *host )
                 }
                 else if( i_msg == HTTPD_MSG_OPTIONS )
                 {
-                    const char *psz_cseq;
+                    const char *psz;
 
                     /* unimplemented */
                     answer->i_proto  = query->i_proto ;
                     answer->i_type   = HTTPD_MSG_ANSWER;
                     answer->i_version= 0;
+
                     answer->i_status = 200;
 
                     answer->i_body = 0;
                     answer->p_body = NULL;
 
-                    psz_cseq = httpd_MsgGet( query, "Cseq" );
-                    httpd_MsgAdd( answer, "Cseq", "%s", psz_cseq ? psz_cseq : "0" );
-                    httpd_MsgAdd( answer, "Server", "VLC Server" );
+                    psz = httpd_MsgGet( query, "Cseq" );
+                    if( psz != NULL )
+                        httpd_MsgAdd( answer, "Cseq", "%s", psz );
+                    psz = httpd_MsgGet( query, "Require" );
+                    if( psz != NULL )
+                        httpd_MsgAdd( query, "Unsupported", "%s", psz );
+                    httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
                     httpd_MsgAdd( answer, "Public", "DESCRIBE, SETUP, "
                                  "TEARDOWN, PLAY, PAUSE" );
-                    httpd_MsgAdd( answer, "Content-Length", "%d",
-                                  answer->i_body );
+                    httpd_MsgAdd( answer, "Content-Length", "0" );
 
                     cl->i_buffer = -1;  /* Force the creation of the answer in
                                          * httpd_ClientSend */