From: Stefano Zacchiroli Date: Tue, 25 Feb 2003 14:13:39 +0000 (+0000) Subject: - added default value for parse_patch function X-Git-Tag: V_0_0_4_1~4 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=9606380c2f02f5ab6ab13808023469a3ae46553c;p=helm.git - added default value for parse_patch function - reindented some tab --- diff --git a/helm/http_getter/http_getter.ml b/helm/http_getter/http_getter.ml index 40f38dc4e..5a84455a1 100644 --- a/helm/http_getter/http_getter.ml +++ b/helm/http_getter/http_getter.ml @@ -42,6 +42,7 @@ let common_headers = [ (* HTTP queries argument parsing *) + (* parse encoding ("format" parameter), default is Enc_normal *) let parse_enc (req: Http_types.request) = try (match req#param "format" with @@ -50,18 +51,23 @@ let parse_enc (req: Http_types.request) = | s -> raise (Http_getter_bad_request ("Invalid format: " ^ s))) with Http_types.Param_not_found _ -> Enc_normal ;; + (* parse "patch_dtd" parameter, default is true *) let parse_patch (req: Http_types.request) = - match req#param "patch_dtd" with - | s when String.lowercase s = "yes" -> true - | s when String.lowercase s = "no" -> false - | s -> raise (Http_getter_bad_request ("Invalid patch_dtd value: " ^ s)) + try + (match req#param "patch_dtd" with + | s when String.lowercase s = "yes" -> true + | s when String.lowercase s = "no" -> false + | s -> raise (Http_getter_bad_request ("Invalid patch_dtd value: " ^ s))) + with Http_types.Param_not_found _ -> true ;; + (* parse output format ("format" parameter), no default value *) let parse_output_format (req: Http_types.request) = match req#param "format" with | s when String.lowercase s = "txt" -> Fmt_text | s when String.lowercase s = "xml" -> Fmt_xml | s -> raise (Http_getter_bad_request ("Invalid /ls format: " ^ s)) ;; + (* parse "baseuri" format for /ls method, no default value *) let parse_ls_uri = let parse_ls_RE = Pcre.regexp "^(\\w+):(.*)$" in let trailing_slash_RE = Pcre.regexp "/+$" in @@ -132,8 +138,8 @@ let return_ls = let (++) (oldann, oldtypes, oldbody) (newann, newtypes, newbody) = ((if newann > oldann then newann else oldann), (if newtypes > oldtypes then newtypes else oldtypes), - (if newbody > oldbody then newbody else oldbody)) - in + (if newbody > oldbody then newbody else oldbody)) + in let basepart_RE = Pcre.regexp "^([^.]*\\.[^.]*)((\\.body)|(\\.types))?(\\.ann)?" in @@ -162,7 +168,7 @@ let return_ls = let oldflags = try Hashtbl.find objs basepart - with Not_found -> (false, No, No) (* no ann, no types no body *) + with Not_found -> (false, No, No) (* no ann, no types, no body *) in let newflags = match o with @@ -201,7 +207,7 @@ let return_ls = in Http_daemon.respond ~headers:(("Content-Type", "text/plain") :: common_headers) - ~body outchan + ~body outchan | Fmt_xml -> let body = sprintf @@ -235,7 +241,7 @@ let return_ls = in Http_daemon.respond ~headers:(("Content-Type", "text/xml") :: common_headers) - ~body outchan + ~body outchan in let (index_line_sep_RE, index_sep_RE, trailing_types_RE, heading_cic_RE, heading_theory_RE, @@ -327,20 +333,14 @@ let callback (req: Http_types.request) outchan = match req#path with | "/getxml" -> let enc = parse_enc req in - let patch = - try parse_patch req with Http_types.Param_not_found _ -> true - in + let patch = parse_patch req in Http_getter_cache.respond_xml ~url:(resolve uri) ~uri ~enc ~patch outchan | "/getxslt" -> - let patch = - try parse_patch req with Http_types.Param_not_found _ -> true - in + let patch = parse_patch req in Http_getter_cache.respond_xsl ~url:(resolve uri) ~patch outchan | "/getdtd" -> - let patch = - try parse_patch req with Http_types.Param_not_found _ -> true - in + let patch = parse_patch req in Http_getter_cache.respond_dtd ~patch ~url:(Http_getter_env.dtd_dir ^ "/" ^ uri) outchan | "/resolve" ->