From: Claudio Sacerdoti Coen Date: Tue, 18 Mar 2003 13:10:36 +0000 (+0000) Subject: Pending changes on the checked-out repository committed. Ask Zack for X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=commitdiff_plain;h=d738fe14f480a254a11993dc3f3289580b985468 Pending changes on the checked-out repository committed. Ask Zack for the changelog ;-) --- diff --git a/helm/searchEngine/Makefile b/helm/searchEngine/Makefile index 3de2997c0..1ae4681e9 100644 --- a/helm/searchEngine/Makefile +++ b/helm/searchEngine/Makefile @@ -1,7 +1,7 @@ REQUIRES = http helm-cic_textual_parser helm-cic_proof_checking \ helm-xml gdome2-xslt helm-cic_unification helm-mathql \ helm-mathql_interpreter helm-mquery_generator -OCAMLOPTIONS = -package "$(REQUIRES)" -pp camlp4o -I ../gTopLevel -thread +OCAMLOPTIONS = -package "$(REQUIRES)" -pp camlp4o -I ../gTopLevel OCAMLC = ocamlfind ocamlc $(OCAMLOPTIONS) OCAMLOPT = ocamlfind ocamlopt $(OCAMLOPTIONS) diff --git a/helm/searchEngine/searchEngine.ml b/helm/searchEngine/searchEngine.ml index 7fa835d8c..999d858aa 100644 --- a/helm/searchEngine/searchEngine.ml +++ b/helm/searchEngine/searchEngine.ml @@ -25,7 +25,7 @@ let debug = true;; let debug_print s = if debug then prerr_endline s;; -Http_common.debug := true;; +(* Http_common.debug := true;; *) open Printf;; @@ -40,7 +40,11 @@ let daemon_name = "Search Engine";; let default_port = 58085;; let port_env_var = "SEARCH_ENGINE_PORT";; -let pages_dir = "html";; (* relative to searchEngine's document root *) +let pages_dir = + try + Sys.getenv "SEARCH_ENGINE_HTML_DIR" + with Not_found -> "html" (* relative to searchEngine's document root *) +;; let interactive_user_uri_choice_TPL = pages_dir ^ "/templateambigpdq1.html";; let interactive_interpretation_choice_TPL = pages_dir ^ "/templateambigpdq2.html";; let final_results_TPL = pages_dir ^ "/templateambigpdq3.html";; @@ -111,6 +115,8 @@ let refine_constraints (x, y, z) = (x, y, z), (Some x, Some y, Some z) in let callback (req: Http_types.request) outchan = try debug_print (sprintf "Received request: %s" req#path); + if req#path <> "/getpage" then + Mqint.init postgresConnectionString; (match req#path with | "/execute" -> let query_string = req#param "query" in @@ -133,8 +139,11 @@ let callback (req: Http_types.request) outchan = let page = remove_fragment (req#param "url") in match page with | page when is_permitted page -> - Http_daemon.respond_file - ~fname:(sprintf "%s/%s" pages_dir (remove_fragment page)) outchan + let fname = sprintf "%s/%s" pages_dir (remove_fragment page) in + debug_print (sprintf "Returning file: %s" fname); + Http_daemon.send_basic_headers ~code:200 outchan; + Http_daemon.send_CRLF outchan; + Http_daemon.send_file ~name:fname outchan | page -> Http_daemon.respond_forbidden ~url:page outchan) | "/searchPattern" -> let term_string = req#param "term" in @@ -319,6 +328,8 @@ let callback (req: Http_types.request) outchan = | invalid_request -> Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan); + if req#path <> "/getpage" then + Mqint.close (); debug_print (sprintf "%s done!" req#path) with | Chat_unfinished -> prerr_endline "Chat unfinished, Try again!" @@ -330,12 +341,11 @@ let callback (req: Http_types.request) outchan = outchan in printf "%s started and listening on port %d\n" daemon_name port; -printf "current directory is %s\n" (Sys.getcwd ()); +printf "Current directory is %s\n" (Sys.getcwd ()); +printf "HTML directory is %s\n" pages_dir; flush stdout; Unix.putenv "http_proxy" ""; Mqint.set_database Mqint.postgres_db; -Mqint.init postgresConnectionString; Http_daemon.start' ~port callback; -Mqint.close (); printf "%s is terminating, bye!\n" daemon_name