]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/ocaml-http/http_daemon.ml
- added some TODO comments
[helm.git] / helm / DEVEL / ocaml-http / http_daemon.ml
index a56780a9fb1252e78921fc80c4c714ec1f16dd15..9e49551f4c6ac742ceaebd1a3040cc624814b9d7 100644 (file)
@@ -59,9 +59,9 @@ let get_code_argument func_name =
     (match code, status with
     | Some c, None -> c
     | None, Some s -> code_of_status s
-    | Some _, Some _ ->
+    | Some _, Some _ -> (* TODO use some static type checking *)
         failwith (func_name ^ " you must give 'code' or 'status', not both")
-    | None, None ->
+    | None, None -> (* TODO use some static type checking *)
         failwith (func_name ^ " you must give 'code' or 'status', not none"))
 
   (** internal: low level for send_status_line *)
@@ -200,7 +200,8 @@ let send_file ?name ?file outchan =
         let f = open_in n in
         f, (fun () -> close_in f)
     | None, Some f -> (f, (fun () -> ()))
-    | _ -> failwith "Daemon.send_file: either name or file must be given")
+    | _ ->  (* TODO use some static type checking *)
+        failwith "Daemon.send_file: either name or file must be given")
   in
   try
     while true do
@@ -275,6 +276,9 @@ let respond_with (res: Http_types.response) outchan =
   res#serialize outchan;
   flush outchan
 
+  (** internal: this exception is raised after a malformed request has been read
+  by a serving process to signal main server (or itself if mode = `Single) to
+  skip to next request *)
 exception Again;;
 
   (* given a Http_parser.parse_request like function, wrap it in a function that
@@ -364,7 +368,9 @@ let start
       flush outchan
     with Again -> ()
   in
-  (server_of_mode mode) ~sockaddr ~timeout daemon_callback 
+  try
+    (server_of_mode mode) ~sockaddr ~timeout daemon_callback 
+  with Quit -> ()
 
   (* OO request *)
 let start'
@@ -380,7 +386,9 @@ let start'
       flush outchan
     with Again -> ()
   in
-  (server_of_mode mode) ~sockaddr ~timeout daemon_callback 
+  try
+    (server_of_mode mode) ~sockaddr ~timeout daemon_callback 
+  with Quit -> ()
 
 module Trivial =
   struct