From 81814dffe8a7bdc7e537b36742dcea44a51fd8ad Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 20 May 2004 16:12:44 +0000 Subject: [PATCH] ported to latest ocaml-http API --- helm/graphs/tools/drawGraph.ml | 6 +++--- helm/graphs/tools/uriSetQueue.ml | 12 ++++++------ helm/http_getter/main.ml | 10 ++++++---- helm/proofChecker/proofChecker.ml | 5 +++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/helm/graphs/tools/drawGraph.ml b/helm/graphs/tools/drawGraph.ml index 1a980fede..9f86feeb0 100644 --- a/helm/graphs/tools/drawGraph.ml +++ b/helm/graphs/tools/drawGraph.ml @@ -82,11 +82,11 @@ let callback (req: Http_types.request) outchan = ignore (Unix.system ( sprintf "make PID=%s clean_tmp; rm -f prova0.%s.dot" pid pid)) | invalid_request -> - Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan) + Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request)) + outchan) with | Http_types.Param_not_found attr_name -> - Http_daemon.respond_error - ~status:(`Client_error `Bad_request) + Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request)) ~body:(sprintf "Parameter '%s' is missing" attr_name) outchan in diff --git a/helm/graphs/tools/uriSetQueue.ml b/helm/graphs/tools/uriSetQueue.ml index 77d15dcad..430275800 100644 --- a/helm/graphs/tools/uriSetQueue.ml +++ b/helm/graphs/tools/uriSetQueue.ml @@ -164,19 +164,19 @@ let callback (req: Http_types.request) outchan = | invalid_request -> debug_print ("Invalid request received"); - Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan); + Http_daemon.respond_error + ~code:(`Status (`Client_error `Bad_request)) outchan); prerr_endline "Request done!\n" with | Http_types.Param_not_found attr_name -> - Http_daemon.respond_error - ~status:(`Client_error `Bad_request) + Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request)) ~body:(sprintf "Parameter '%s' is missing" attr_name) outchan | Failure "int_of_string" -> (* error in converting some paramters *) - Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan - | Queue_not_found queue_name -> Http_daemon.respond_error - ~status:(`Client_error `Bad_request) + ~code:(`Status (`Client_error `Bad_request)) outchan + | Queue_not_found queue_name -> + Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request)) ~body:(sprintf "Queue '%d' is not defined" queue_name) outchan in diff --git a/helm/http_getter/main.ml b/helm/http_getter/main.ml index 6501afdaf..8fa671ab9 100644 --- a/helm/http_getter/main.ml +++ b/helm/http_getter/main.ml @@ -123,10 +123,11 @@ let return_html_internal_error = mk_return_fun pp_internal_error "text/html" let return_html_msg = mk_return_fun pp_msg "text/html" let return_html_raw = mk_return_fun null_pp "text/html" let return_xml_raw = mk_return_fun null_pp "text/xml" -let return_400 body outchan = Http_daemon.respond_error ~code:400 ~body outchan +let return_400 body outchan = + Http_daemon.respond_error ~code:(`Code 400) ~body outchan let return_all_foo_uris doctype uris outchan = - Http_daemon.send_basic_headers ~code:200 outchan; + Http_daemon.send_basic_headers ~code:(`Code 200) outchan; Http_daemon.send_header "Content-Type" "text/xml" outchan; Http_daemon.send_headers common_headers outchan; Http_daemon.send_CRLF outchan; @@ -233,7 +234,7 @@ let log_failure msg = Http_getter_logger.log ("Request not fulfilled: " ^ msg) * given output channel. Response is sent embedded in an HTML document. * Channel is closed afterwards. *) let send_log_to ?prepend action outchan = - Http_daemon.send_basic_headers ~code:200 outchan; + Http_daemon.send_basic_headers ~code:(`Code 200) outchan; Http_daemon.send_header "Content-Type" "text/html" outchan; Http_daemon.send_CRLF outchan; output_string outchan "\n"; flush outchan; @@ -306,7 +307,8 @@ let callback (req: Http_types.request) outchan = | "/getempty" -> Http_daemon.respond ~body:Http_getter_const.empty_xml outchan | invalid_request -> - Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan); + Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request)) + outchan); Http_getter_logger.log "Done!\n" with | Http_types.Param_not_found attr_name -> diff --git a/helm/proofChecker/proofChecker.ml b/helm/proofChecker/proofChecker.ml index 6513d4f93..278413bde 100644 --- a/helm/proofChecker/proofChecker.ml +++ b/helm/proofChecker/proofChecker.ml @@ -50,7 +50,8 @@ END let bad_request outchan = printf "INVALID REQUEST !!!!!\n\n"; flush stdout; - Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan; + Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request)) + outchan; flush outchan ;; @@ -98,7 +99,7 @@ let callback (req : Http_types.request) outchan' = outchan := outchan' ; try let uri = req#param "uri" in - Http_daemon.send_basic_headers ~code:200 outchan' ; + Http_daemon.send_basic_headers ~code:(`Code 200) outchan' ; Http_daemon.send_header "Content-type" "text/html" outchan' ; Http_daemon.send_CRLF outchan' ; printf "Request to proof-check \"%s\"..." uri; -- 2.39.2