From: Stefano Zacchiroli Date: Thu, 9 Jan 2003 07:56:56 +0000 (+0000) Subject: - added return_html_raw to Http_getter_common X-Git-Tag: v0_3_99~60 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=6a9be767a19f39aa862f989d8dbbe186b71db0ca;p=helm.git - added return_html_raw to Http_getter_common - renamed for coherence return_xml_msg to return_xml_raw --- diff --git a/helm/http_getter/http_getter.ml b/helm/http_getter/http_getter.ml index 09a49a308..7c5fafa11 100644 --- a/helm/http_getter/http_getter.ml +++ b/helm/http_getter/http_getter.ml @@ -314,7 +314,7 @@ let callback (req: Http_types.request) outchan = debug_print ("Connection from " ^ req#clientAddr); debug_print ("Received request: " ^ req#path); (match req#path with - | "/help" -> return_html_msg Http_getter_const.usage_string outchan + | "/help" -> return_html_raw Http_getter_const.usage_string outchan | "/getxml" | "/getxslt" | "/getdtd" | "/resolve" | "/register" -> (let uri = req#param "uri" in (* common parameter *) match req#path with @@ -338,11 +338,11 @@ let callback (req: Http_types.request) outchan = ~patch ~url:(Http_getter_env.dtd_dir ^ "/" ^ uri) outchan | "/resolve" -> (try - return_xml_msg + return_xml_raw (sprintf "\n" (resolve uri)) outchan with Http_getter_unresolvable_URI uri -> - return_xml_msg "\n" outchan) + return_xml_raw "\n" outchan) | "/register" -> let url = req#param "url" in register uri url; diff --git a/helm/http_getter/http_getter_common.ml b/helm/http_getter/http_getter_common.ml index 0e66b2035..b7cbc936c 100644 --- a/helm/http_getter/http_getter_common.ml +++ b/helm/http_getter/http_getter_common.ml @@ -95,7 +95,8 @@ let mk_return_fun pp_fun contype msg outchan = let return_html_error = mk_return_fun pp_error "text/html" 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_xml_msg = mk_return_fun null_pp "text/xml" +let return_html_raw = mk_return_fun null_pp "text/html" +let return_xml_raw = mk_return_fun null_pp "text/xml" let return_file ~fname ?contype ?contenc ?(patch_fun = fun x -> x) outchan = let headers = match (contype, contenc) with diff --git a/helm/http_getter/http_getter_common.mli b/helm/http_getter/http_getter_common.mli index 0c21ba6ff..9ac5aad6f 100644 --- a/helm/http_getter/http_getter_common.mli +++ b/helm/http_getter/http_getter_common.mli @@ -43,8 +43,15 @@ val patch_dtd : string -> string val return_html_error: string -> out_channel -> unit val return_html_internal_error: string -> out_channel -> unit + (** return an HTML HTTP response from the given string, embedding it in an + "H1" element of an HTML page; content-type is set to text/html *) val return_html_msg: string -> out_channel -> unit -val return_xml_msg: string -> out_channel -> unit + (** return an HTTP response using given string as content; content-type is set + to text/html *) +val return_html_raw: string -> out_channel -> unit + (** return an HTTP response using given string as content; content-type is set + to text/xml *) +val return_xml_raw: string -> out_channel -> unit (** return a bad request http response *) val return_400: string -> out_channel -> unit (**