Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
+open Printf;;
+
let dump_args path args =
Printf.sprintf
"PATH: %s\nARGS:\n%s"
(String.concat
""
(List.map
- (fun (name, value) -> "\tNAME: " ^ name ^ ", VALUE: " ^ value ^ "\n")
+ (fun (name, value) -> sprintf "\tNAME: '%s', VALUE: '%s'\n" name value)
args))
in
let callback path args outchan =
match path with
| "/gone" ->
- Http.Daemon.respond_redirect
+ Http_daemon.respond_redirect
~location:"/foo" ~body:"REDIRECT" ~code:302 outchan
| "/error" ->
- Http.Daemon.respond_error ~body:"ERROR" ~code:500 outchan
+ Http_daemon.respond_error ~body:"ERROR" ~code:500 outchan
| _ ->
begin
- Http.Daemon.send_basic_headers ~code:200 outchan;
- Http.Daemon.send_CRLF outchan;
+ Http_daemon.send_basic_headers ~code:200 outchan;
+ Http_daemon.send_CRLF outchan;
output_string outchan (dump_args path args)
end
in
-print_endline "Starting custom Http.Daemon ...";
+print_endline "Starting custom Http_daemon ...";
flush stdout;
-Http.Daemon.start ~addr:"127.0.0.1" ~port:9999 callback
+Http_daemon.start ~port:9999 callback