(* constants *)
-let configuration_file = "/projects/helm/etc/http_getter.conf.xml"
+(* let configuration_file = "/projects/helm/etc/http_getter.conf.xml" *)
+let configuration_file = "http_getter.conf.xml"
let common_headers = [
"Cache-Control", "no-cache";
(* HTTP queries argument parsing *)
- (* parse encoding ("format" parameter), default is Enc_normal *)
+ (* parse encoding ("format" parameter), default is `Normal *)
let parse_enc (req: Http_types.request) =
try
(match req#param "format" with
- | "normal" -> Enc_normal
- | "gz" -> Enc_gzipped
+ | "normal" -> `Normal
+ | "gz" -> `Gzipped
| s -> raise (Bad_request ("Invalid format: " ^ s)))
- with Http_types.Param_not_found _ -> Enc_normal
+ with Http_types.Param_not_found _ -> `Normal
(* parse "patch_dtd" parameter, default is true *)
let parse_patch (req: Http_types.request) =
(* parse output format ("format" parameter), no default value *)
let parse_output_format meth (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 when String.lowercase s = "txt" -> `Text
+ | s when String.lowercase s = "xml" -> `Xml
| s -> raise (Bad_request ("Invalid /" ^ meth ^ " format: " ^ s))
(* parse "baseuri" format for /ls method, no default value *)
let return_all_xml_uris fmt outchan =
let uris = Http_getter.getalluris () in
match fmt with
- | Fmt_text ->
+ | `Text ->
let buf = Buffer.create 10240 in
List.iter (bprintf buf "%s\n") uris ;
let body = Buffer.contents buf in
Http_daemon.respond
~headers:(("Content-Type", "text/plain") :: common_headers)
~body outchan
- | Fmt_xml ->
+ | `Xml ->
return_all_foo_uris "alluris" uris outchan
let return_all_rdf_uris classs outchan =
let ls_items = Http_getter.ls xmluri in
let buf = Buffer.create 10240 in
(match fmt with
- | Fmt_text ->
+ | `Text ->
List.iter
(function
| Ls_section dir -> bprintf buf "dir, %s\n" dir
(string_of_ls_flag obj.body)
(string_of_ls_flag obj.proof_tree))
ls_items
- | Fmt_xml ->
+ | `Xml ->
Buffer.add_string buf "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
bprintf buf "<!DOCTYPE ls SYSTEM \"%s/getdtd?uri=ls.dtd\">\n"
(Lazy.force Http_getter_env.my_own_url);