prerr_endline "Warning: invalid port, reverting to default";
default_port
in
-let callback req outchan =
+let callback (req: Http_types.request) outchan =
try
- let res = new Http_response.response in
+ let res = new Http_response.response () in
res#addBasicHeaders;
res#setContentType "text/xml";
(match req#path with
end
end
in
- res#setContents (sprintf "<?xml version=\"1.0\"?>\n<%s/>\n" result);
+ res#setBody (sprintf "<?xml version=\"1.0\"?>\n<%s/>\n" result);
if debug then res#serialize stderr;
Http_daemon.respond_with res outchan
let queue = get_queue pid in
let result = string_of_bool (queue.overflowed) in
debug_print (sprintf "%d queue is_overflowed = %s" pid result);
- res#setContents (sprintf "<?xml version=\"1.0\"?>\n<%s/>\n" result);
+ res#setBody (sprintf "<?xml version=\"1.0\"?>\n<%s/>\n" result);
if debug then res#serialize stderr;
Http_daemon.respond_with res outchan
with Queue_not_found p ->
assert (p = pid);
add_queue pid size);
- res#setContents "<?xml version=\"1.0\"?>\n<done/>\n";
+ res#setBody "<?xml version=\"1.0\"?>\n<done/>\n";
if debug then res#serialize stderr;
Http_daemon.respond_with res outchan
uri
with Queue.Empty -> "<empty/>"
in
- res#setContents ("<?xml version=\"1.0\"?>\n" ^ element ^ "\n");
+ res#setBody ("<?xml version=\"1.0\"?>\n" ^ element ^ "\n");
if debug then res#serialize stderr;
Http_daemon.respond_with res outchan
let pid = int_of_string (req#param "PID") in
remove_queue pid;
debug_print (sprintf "Resetting queue '%d'" pid);
- res#setContents "<?xml version=\"1.0\"?>\n<done/>\n";
+ res#setBody "<?xml version=\"1.0\"?>\n<done/>\n";
if debug then res#serialize stderr;
Http_daemon.respond_with res outchan
Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan);
prerr_endline "Request done!\n"
with
- | Http_request.Param_not_found attr_name ->
+ | Http_types.Param_not_found attr_name ->
Http_daemon.respond_error
~status:(`Client_error `Bad_request)
~body:(sprintf "Parameter '%s' is missing" attr_name)
printf "%s started and listening on port %d\n" daemon_name port;
flush stdout;
-Http_daemon.start' ~port ~fork:false callback;
+Http_daemon.start' ~port ~mode:`Thread callback;
printf "%s is terminating, bye!\n" daemon_name