]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
restructure code slightly so we get common header parsing for RTSP as well
authorAndreas Öman <andreas@lonelycoder.com>
Fri, 2 Nov 2007 22:20:55 +0000 (22:20 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Fri, 2 Nov 2007 22:20:55 +0000 (22:20 +0000)
http.c

diff --git a/http.c b/http.c
index 9dc65832e97563d4abff4b03cf8fcf57212a69f0..f18ff9a6526a697944952a0a908698a6d4bbcce7 100644 (file)
--- a/http.c
+++ b/http.c
@@ -167,7 +167,7 @@ http_unauthorized(http_connection_t *hc)
 
 
 /**
- * GET
+ * HTTP GET
  */
 static void
 http_cmd_get(http_connection_t *hc)
@@ -177,11 +177,28 @@ http_cmd_get(http_connection_t *hc)
 
 
 /**
- * Process a HTTP request, extract info from headers, dispatch command
- * and clean up
+ * Process a HTTP request
  */
-static int
+static void
 http_process_request(http_connection_t *hc)
+{
+  switch(hc->hc_cmd) {
+  default:
+    http_error(hc, HTTP_STATUS_BAD_REQUEST);
+    break;
+  case HTTP_CMD_GET:
+    http_cmd_get(hc); 
+    break;
+  }
+}
+
+
+/**
+ * Process a request, extract info from headers, dispatch command and
+ * clean up
+ */
+static int
+process_request(http_connection_t *hc)
 {
   char *v, *argv[2];
   int n;
@@ -192,6 +209,7 @@ http_process_request(http_connection_t *hc)
 
   switch(hc->hc_version) {
   case RTSP_VERSION_1_0:
+    hc->hc_keep_alive = 1;
     break;
 
   case HTTP_VERSION_0_9:
@@ -221,17 +239,21 @@ http_process_request(http_connection_t *hc)
     }
   }
 
-  /* Process the command */
+  
 
-  switch(hc->hc_cmd) {
-  default:
-    http_error(hc, HTTP_STATUS_BAD_REQUEST);
+  switch(hc->hc_version) {
+  case RTSP_VERSION_1_0:
+    rtsp_process_request(hc);
     break;
-  case HTTP_CMD_GET:
-    http_cmd_get(hc); 
+
+  case HTTP_VERSION_0_9:
+  case HTTP_VERSION_1_0:
+  case HTTP_VERSION_1_1:
+    http_process_request(hc);
     break;
   }
 
+
   /* Clean up */
 
   free(hc->hc_username);
@@ -285,7 +307,7 @@ http_con_parse(void *aux, char *buf)
       hc->hc_state = HTTP_CON_READ_HEADER;
     } else {
       hc->hc_version = HTTP_VERSION_0_9;
-      return http_process_request(hc);
+      return process_request(hc);
     }
 
     break;
@@ -293,16 +315,8 @@ http_con_parse(void *aux, char *buf)
   case HTTP_CON_READ_HEADER:
     if(*buf == 0) { 
       /* Empty crlf line, end of header lines */
-
       hc->hc_state = HTTP_CON_WAIT_REQUEST;
-
-      switch(hc->hc_version) {
-      case RTSP_VERSION_1_0:
-       return rtsp_process_request(hc);
-
-      default:
-       return http_process_request(hc);
-      }
+      return process_request(hc);
     }
 
     n = http_tokenize(buf, argv, 2, -1);