From: Claudio Sacerdoti Coen
Date: Tue, 24 Feb 2004 10:05:03 +0000 (+0000)
Subject: Added parameter format=text|xml to getalluris.
X-Git-Tag: v0_0_4~96
X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=dbba2a9addd1244a9b62f61b36dfc5338fbe850f;p=helm.git
Added parameter format=text|xml to getalluris.
---
diff --git a/helm/http_getter/main.ml b/helm/http_getter/main.ml
index 7722a2cdc..eafbc06e6 100644
--- a/helm/http_getter/main.ml
+++ b/helm/http_getter/main.ml
@@ -64,11 +64,11 @@ let parse_patch (req: Http_types.request) =
with Http_types.Param_not_found _ -> true
(* parse output format ("format" parameter), no default value *)
-let parse_output_format (req: Http_types.request) =
+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 -> raise (Bad_request ("Invalid /ls format: " ^ s))
+ | s -> raise (Bad_request ("Invalid /" ^ meth ^ " format: " ^ s))
(* parse "baseuri" format for /ls method, no default value *)
let parse_ls_uri =
@@ -132,8 +132,19 @@ let return_all_foo_uris doctype uris outchan =
uris;
output_string outchan (sprintf "%s>\n" doctype)
-let return_all_xml_uris outchan =
- return_all_foo_uris "alluris" (Http_getter.getalluris ()) outchan
+let return_all_xml_uris fmt outchan =
+ let uris = Http_getter.getalluris () in
+ match fmt with
+ | Fmt_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 ->
+ return_all_foo_uris "alluris" uris outchan
+
let return_all_rdf_uris classs outchan =
return_all_foo_uris "allrdfuris" (Http_getter.getallrdfuris classs) outchan
@@ -253,9 +264,11 @@ let callback (req: Http_types.request) outchan =
(sprintf "Removed server at position %d
\n%s"
position (HelmLogger.html_of_html_msg log))
outchan
- | "/getalluris" -> return_all_xml_uris outchan
+ | "/getalluris" ->
+ return_all_xml_uris (parse_output_format "getalluris" req) outchan
| "/getallrdfuris" -> return_all_rdf_uris (parse_rdf_class req) outchan
- | "/ls" -> return_ls (parse_ls_uri req) (parse_output_format req) outchan
+ | "/ls" ->
+ return_ls (parse_ls_uri req) (parse_output_format "ls" req) outchan
| "/getempty" ->
Http_daemon.respond ~body:Http_getter_const.empty_xml outchan
| invalid_request ->
diff --git a/helm/ocaml/getter/http_getter_const.ml b/helm/ocaml/getter/http_getter_const.ml
index a4eac83e5..4e68f95d9 100644
--- a/helm/ocaml/getter/http_getter_const.ml
+++ b/helm/ocaml/getter/http_getter_const.ml
@@ -83,7 +83,7 @@ let usage_string configuration =
clean_cache
- getalluris
+ getalluris?format=(txt|xml)
getallrdfuris