X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Focaml-http%2Fhttp_daemon.ml;h=9e49551f4c6ac742ceaebd1a3040cc624814b9d7;hb=3e666920212c55ad4960ee2b30335acf8eb40560;hp=a56780a9fb1252e78921fc80c4c714ec1f16dd15;hpb=ca9cd0aeee0ce78a891f7f6091ca8704231a446d;p=helm.git diff --git a/helm/DEVEL/ocaml-http/http_daemon.ml b/helm/DEVEL/ocaml-http/http_daemon.ml index a56780a9f..9e49551f4 100644 --- a/helm/DEVEL/ocaml-http/http_daemon.ml +++ b/helm/DEVEL/ocaml-http/http_daemon.ml @@ -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