From c5c48f3d3515f1dd95657245922ec1f340e17f70 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Sun, 5 Jan 2003 14:16:01 +0000 Subject: [PATCH] - added some TODO comments - added support for callback raised Quit exception --- helm/DEVEL/ocaml-http/debian/changelog | 3 +++ helm/DEVEL/ocaml-http/http_daemon.ml | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/helm/DEVEL/ocaml-http/debian/changelog b/helm/DEVEL/ocaml-http/debian/changelog index ff405be86..e8fddf21e 100644 --- a/helm/DEVEL/ocaml-http/debian/changelog +++ b/helm/DEVEL/ocaml-http/debian/changelog @@ -9,6 +9,9 @@ ocaml-http (0.0.7) unstable; urgency=low * Added OO daemon interfaces ("daemon" and "connection" classes) * Use Pcre to perform sanity test on headers instead of home made parsing + * Callback functions can raise Http_types.Quit to have main daemon + quit + * Case-insensitive handling of header names -- Stefano Zacchiroli Wed, 25 Dec 2002 16:22:31 +0100 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 -- 2.39.2