]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/http_getter/http_getter.ml
Resolve fixed: when an URI was well-formed but not found in a map, unresolved
[helm.git] / helm / http_getter / http_getter.ml
index 1e04ae8789ac06bab757c1b45398d7947cc2a3c3..02877b012c55690222fb7c2a87763225706f82bd 100644 (file)
@@ -30,6 +30,14 @@ open Http_getter_types;;
 open Http_getter_debugger;;
 open Printf;;
 
+  (* constants *)
+
+let common_headers = [
+  "Cache-Control", "no-cache";
+  "Pragma", "no-cache";
+  "Expires", "0"
+]
+
   (* HTTP queries argument parsing *)
 
 let parse_enc (req: Http_types.request) =
@@ -80,7 +88,12 @@ let map_of_uri = function
   | uri when is_xsl_uri uri -> xsl_map
   | uri -> raise (Http_getter_unresolvable_URI uri)
 in
-let resolve uri = (map_of_uri uri)#resolve uri in
+let resolve uri =
+  try
+    (map_of_uri uri)#resolve uri
+  with Http_getter_map.Key_not_found _ ->
+    raise (Http_getter_unresolvable_URI uri)
+in
 let register uri =  (map_of_uri uri )#add uri in
 let return_all_foo_uris map doctype filter outchan =
   (** return all URIs contained in 'map' which satisfy predicate 'filter'; URIs
@@ -88,6 +101,7 @@ let return_all_foo_uris map doctype filter outchan =
   *)
   Http_daemon.send_basic_headers ~code:200 outchan;
   Http_daemon.send_header "Content-Type" "text/xml" outchan;
+  Http_daemon.send_headers common_headers outchan;
   Http_daemon.send_CRLF outchan;
   output_string
     outchan
@@ -181,7 +195,8 @@ let return_ls =
             objs "")
         in
         Http_daemon.respond
-          ~headers:["Content-Type", "text/plain"] ~body outchan
+          ~headers:(("Content-Type", "text/plain") :: common_headers)
+         ~body outchan
     | Fmt_xml ->
         let body =
           sprintf
@@ -214,7 +229,8 @@ let return_ls =
               objs ""))
         in
         Http_daemon.respond
-          ~headers:["Content-Type", "text/xml"] ~body outchan
+          ~headers:(("Content-Type", "text/xml") :: common_headers)
+         ~body outchan
 in
 let (index_line_sep_RE, index_sep_RE, trailing_types_RE,
     heading_cic_RE, heading_theory_RE,