[GanameDemo: Give proper error code to the client when busy
flux@modeemi.fi**20090925191251] {
hunk ./ganameDemo.ml 59
- cgi#out_channel#output_string "
Sorry, I'm busy. Only one request concurrently.
"
-
-let page (cgi : Netcgi.cgi) =
hunk ./ganameDemo.ml 61
+ ~status:`Service_unavailable
hunk ./ganameDemo.ml 64
- if cgi#argument_exists "input" && cgi#argument_exists "examples" then
- if incr_operations_if_zero () then
- Std.finally decr_operations
- (fun () ->
- try
- let examples = List.map (fun s -> String.split s "=") (Pcre.split ~pat:"\r\n" (cgi#argument "examples")#value) in
- let inputs = Pcre.split ~pat:"\r\n" (cgi#argument "input")#value in
- perform_operations cgi examples inputs;
- with exn ->
- o cgi "Error: %s" (Printexc.to_string exn);
- ) ()
+ cgi#out_channel#output_string "Sorry, I'm busy. Only one request concurrently.
"
+
+let page (cgi : Netcgi.cgi) =
+ let default_header () =
+ cgi#set_header
+ ~cache:`No_cache
+ ~content_type:"text/html; charset=iso-8859-15"
+ ()
+ in
+ if cgi#argument_exists "input" && cgi#argument_exists "examples" then
+ if incr_operations_if_zero () then
+ Std.finally decr_operations
+ (fun () ->
+ try
+ default_header ();
+ let examples = List.map (fun s -> String.split s "=") (Pcre.split ~pat:"\r\n" (cgi#argument "examples")#value) in
+ let inputs = Pcre.split ~pat:"\r\n" (cgi#argument "input")#value in
+ perform_operations cgi examples inputs;
+ with exn ->
+ o cgi "Error: %s" (Printexc.to_string exn);
+ ) ()
+ else
+ busy_page cgi
hunk ./ganameDemo.ml 88
- busy_page cgi
- else
- query_page cgi;
- cgi#out_channel#commit_work ()
+ ( default_header ();
+ query_page cgi );
+ cgi#out_channel#commit_work ()
}