*)
let callback req outchan =
- output_string outchan "FOO\n";
- flush outchan;
- Unix.sleep 5;
Http_daemon.respond_error ~body:"AH AH AH :-P" outchan
in
-Http_daemon.start' ~port:9999 ~fork:false callback
+Http_daemon.start' ~port:9999 ~fork:false ~timeout:(Some 5) callback
*)
open Neturl;;
+open Printf;;
exception Malformed_query of string
exception Malformed_query_binding of string * string
let query_params =
try split_query_params (url_query request_uri) with Not_found -> []
in
+ Http_common.debug_print
+ (sprintf
+ "recevied request; path: %s; params: %s"
+ path
+ (String.concat
+ ", "
+ (List.map (fun (n, v) -> n ^ "=" ^ v) query_params)));
(path, query_params)
| _ -> raise (Malformed_request request_line)
let (inchan, outchan) =
(Unix.in_channel_of_descr suck, Unix.out_channel_of_descr suck)
in
- (try callback inchan outchan with Timeout -> ());
+ (try
+ callback inchan outchan;
+ ignore (Unix.alarm 0)
+ with Timeout -> ());
close_out outchan (* this close also inchan, because socket is the same *)
done