- cgi # set_header
- ~cache:`No_cache
- ~content_type:"text/xml; charset=\"utf-8\""
- ();
- let filename = cgi # argument_value "file" in
- prerr_endline ("reading file " ^ filename);
- let body =
- Netencoding.Html.encode ~in_enc:`Enc_utf8 ~prefer_name:false ()
- (read_file filename) in
- prerr_endline ("sending:\nBEGIN\n" ^ body ^ "\nEND");
- let body = "<file>" ^ body ^ "</file>" in
- let baseuri, incpaths =
- try
- let root, baseuri, _fname, _tgt =
- Librarian.baseuri_of_script ~include_paths:[] filename in
- let includes =
- try
- Str.split (Str.regexp " ")
- (List.assoc "include_paths" (Librarian.load_root_file (root^"/root")))
- with Not_found -> []
- in
- let rc = root :: includes in
- List.iter (HLog.debug) rc; baseuri, rc
- with
- Librarian.NoRootFor _ | Librarian.FileNotFound _ -> "",[] in
- include_paths := incpaths;
- status := (!status)#set_baseuri baseuri;
- cgi#out_channel#output_string body;
+ let env = cgi#environment in
+ (try
+ let sid = Uuidm.of_string (Netcgi.Cookie.value (env#cookie "session")) in
+ let sid = HExtlib.unopt sid in
+ cgi # set_header
+ ~cache:`No_cache
+ ~content_type:"text/xml; charset=\"utf-8\""
+ ();
+ let filename = cgi # argument_value "file" in
+ prerr_endline ("reading file " ^ filename);
+ let body =
+ Netencoding.Html.encode ~in_enc:`Enc_utf8 ~prefer_name:false ()
+ (read_file filename) in
+ prerr_endline ("sending:\nBEGIN\n" ^ body ^ "\nEND");
+ let body = "<file>" ^ body ^ "</file>" in
+ let baseuri, incpaths =
+ try
+ let root, baseuri, _fname, _tgt =
+ Librarian.baseuri_of_script ~include_paths:[] filename in
+ let includes =
+ try
+ Str.split (Str.regexp " ")
+ (List.assoc "include_paths" (Librarian.load_root_file (root^"/root")))
+ with Not_found -> []
+ in
+ let rc = root :: includes in
+ List.iter (HLog.debug) rc; baseuri, rc
+ with
+ Librarian.NoRootFor _ | Librarian.FileNotFound _ -> "",[] in
+ include_paths := incpaths;
+ let status = MatitaAuthentication.get_status sid in
+ MatitaAuthentication.set_status sid (status#set_baseuri baseuri);
+ cgi#out_channel#output_string body;
+ with
+ | Not_found _ ->
+ cgi # set_header
+ ~status:`Internal_server_error
+ ~cache:`No_cache
+ ~content_type:"text/xml; charset=\"utf-8\""
+ ());