]> matita.cs.unibo.it Git - helm.git/commitdiff
1) fromdos on any html/* file
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Thu, 10 Apr 2003 15:26:17 +0000 (15:26 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Thu, 10 Apr 2003 15:26:17 +0000 (15:26 +0000)
2) added a new method ask_uwobo to copy to the user a document that is
   asked to UWOBO (i.e. given a URL, it checks that it is a request to
   a trusted server)
3) templateambipdq?.html changed in such a way that no character that needs
   XML escaping happears. In this way we can apply stylesheets on them and
   what we get is valid HTML + JavaScript
4) All the functions that used to print the result as ASCII have been changed
   to generate an HELM Theory File.
5) The JavaScript code now asks the searchEngine to ask_uwobo an URL that
   is obtained by asking UWOBO to apply the stylesheets from theory files to
   HTML. The UWOBO URL (and parameters) are now hard-coded in JavaScript ;-((

As a result, we now have a very pretty rendering of the results. The
hyperlinks are enabled and fully working. Well done!

helm/searchEngine/Makefile
helm/searchEngine/html/editor.html
helm/searchEngine/html/editorpdq.html
helm/searchEngine/html/index.html
helm/searchEngine/html/loc_obj.html
helm/searchEngine/html/templateambigpdq1.html
helm/searchEngine/html/templateambigpdq2.html
helm/searchEngine/html/templateambigpdq3.html
helm/searchEngine/searchEngine.ml

index 1ae4681e96a3ac5f458f2b50972cdbece8a54371..7145312c0fff3a4e8a049983b768d4d3768735bf 100644 (file)
@@ -1,6 +1,6 @@
 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
+           helm-mathql_interpreter helm-mquery_generator netclient
 OCAMLOPTIONS = -package "$(REQUIRES)" -pp camlp4o -I ../gTopLevel
 OCAMLC = ocamlfind ocamlc $(OCAMLOPTIONS)
 OCAMLOPT = ocamlfind ocamlopt $(OCAMLOPTIONS)
index c2733a3c96677c04826c161598422788f6bc7c30..1e6afe7d06e9f5c35cd821f4370833caedc6c7f4 100644 (file)
@@ -4,7 +4,7 @@
 qbf=/[[^\[\]<>]*|<set>|<val>|<boole>]*/
 function invia()
        {
-       window.open(top.topurl+"/execute?query="+escape(document.edit.qta.value),"cw");
+       window.open(top.ask_uwobo(top.topurl+"/execute?query="+escape(document.edit.qta.value)),"cw");
        }
 function parse1()
        {
index 07aa2b7753848a9f1b593bfa41fe245a3be7eda3..27f070964ad439b6589ffc3d52e5d8e5b5aff44a 100644 (file)
@@ -37,8 +37,8 @@ function invia()
                        top.listaliases=top.listaliases+escape(top.aliasglob[i]+" ");
                        }
                //alert(top.listaliases);
-    window.open(top.topurl+"/searchPattern?term="+escape(document.invio.expression.value)+"&aliases="+top.listaliases,"cw");
-    }
+    window.open(top.ask_uwobo(top.topurl+"/searchPattern?term="+escape(document.invio.expression.value)+"&aliases="+top.listaliases),"cw");
+        }
                //window.open(top.topurl+top.action+"templateambigpdq2.html","bw")}     
        else {alert("Please complete the query before.")}
        }
index 7e09b91f3710ef8e1f7bcbc970b336b62b677436..879bdd646380e0807e17e3d51b891f920502aa4d 100644 (file)
@@ -42,6 +42,10 @@ function initialize()
        actinput=0;
        numeroazioniannullate=0;
        }
+function ask_uwobo(url)
+       {
+         return (top.topurl+"/ask_uwobo?url="+escape("http://mowgli.cs.unibo.it:58080/apply?xmluri=" + escape(url) + "&keys=T1%2CT2%2CL%2CE&param.processorURL=http%3A//mowgli.cs.unibo.it%3A58080/&param.getterURL=http%3A//mowgli.cs.unibo.it%3A58081/&param.proofcheckerURL=http%3A//mowgli.cs.unibo.it%3A58084/&param.draw_graphURL=http%3A//mowgli.cs.unibo.it%3A58083/&param.uri_set_queueURL=http%3A//mowgli.cs.unibo.it%3A58082/&param.UNICODEvsSYMBOL=unicode&param.keys=d_c%2CC1%2CHC2%2CL&param.thkeys=T1%2CT2%2CL%2CE&param.embedkeys=d_c%2CTC1%2CHC2%2CL&param.doctype-public=-//W3C//DTD%20XHTML%201.0%20Transitional//EN&param.encoding=iso-8859-1&param.thencoding=iso-8859-1&param.media-type=text/html&param.thmedia-type=text/html&param.interfaceURL=http%3A//helm.cs.unibo.it/helm/html/cic/index.html&param.thinterfaceURL=http%3A//helm.cs.unibo.it/helm/html/theory/index.html&param.CICURI=dummy:query_result&param.naturalLanguage=yes&param.annotations=no&param.topurl=http://helm.cs.unibo.it/helm&prop.method=html"));
+       }
 function help(w) // quando invocata, visualizza l' help relativo ad un oggetto. Di solito รจ legata ad un evento onFocus o onMouseOver.  
        {
        hw.document.close();
@@ -398,6 +402,137 @@ var topurl=document.location.protocol+'//'+document.location.host;
 //var topurl="";
 var action="/getpage?url=";
 //var action="";
+
+
+// UTILITY FUNCTIONS FOR templateambigpdq1.html
+function templateambigpdq1_armageddon()
+       {
+       top.initialize();
+       top.window.open(top.topurl+top.action+"start.html","qw");
+       top.window.open(top.topurl+top.action+"blank.html","cw");
+       top.window.open(top.topurl+top.action+"blank.html","hw");
+       top.window.open(top.topurl+top.action+"blank.html","gw");
+       top.window.open(top.topurl+top.action+"blank.html","sw");
+       }
+
+function templateambigpdq1_resetta()
+       {
+       if (confirm("This will erase your query and start a new one. Are you sure you want to do this?"))
+               {templateambigpdq1_armageddon();}
+       }
+
+function templateambigpdq1_listauri(document,elenco)
+       {
+       for (i=0;i<elenco.length;i++)
+               {
+               document.write("<input type=checkbox name=uricheck value="+elenco[i]+"> "+elenco[i]+"<br>"); 
+               }
+       }
+
+function templateambigpdq1_invia(document,top,elenco,ident)
+       {
+       vecchiavlds=top.vlds.length;
+       stringa=top.topurl+"/searchPattern?term="+top.terminecic;
+       stringa=stringa+"&aliases="+top.listaliases;
+       stringa=stringa+"&choices=";
+        var choices = "";
+       top.vlds[top.vlds.length]=ident;
+       for (j=0;j<elenco.length;j++)
+               {
+               if (document.disamb.uricheck[j].checked)
+                       {
+                       top.vlds[top.vlds.length]=document.disamb.uricheck[j].value;
+                       }
+               }
+       top.vlds[top.vlds.length]=";";
+       for (j=0;j<top.vlds.length;j++)
+       {
+           choices=choices+(top.vlds[j]==";"?";":escape(top.vlds[j]))+" ";
+       }
+       choices=choices.substring(0,choices.length-2);
+        stringa=stringa+escape(choices);
+       if (top.vlds.length==vecchiavlds){alert("You must select at least one of the options.");}
+       else
+       {
+          window.open(ask_uwobo(stringa),"cw");
+       }
+       } 
+
+  function templateambigpdq1_selezionaCostanti(document,elenco) {
+    for (i=0; i<elenco.length; i++) {
+      if (elenco[i].substring(elenco[i].length-4, elenco[i].length) != ".var") {
+        document.disamb.uricheck[i].checked = true;
+      } else {
+        document.disamb.uricheck[i].checked = false;
+      }
+    }
+  }
+
+
+
+// UTILITY FUNCTIONS FOR templateambigpdq2.html
+function templateambigpdq2_armageddon()
+       {
+       top.initialize();
+       top.window.open(top.topurl+top.action+"start.html","qw");
+       top.window.open(top.topurl+top.action+"blank.html","cw");
+       top.window.open(top.topurl+top.action+"blank.html","hw");
+       top.window.open(top.topurl+top.action+"blank.html","gw");
+       top.window.open(top.topurl+top.action+"blank.html","sw");
+       }
+
+function templateambigpdq2_resetta()
+       {
+       if (confirm("This will erase your query and start a new one. Are you sure you want to do this?"))
+               {templateambigpdq2_armageddon();}
+       }
+
+function templateambigpdq2_listainterpretazioni(document,elenco,labels)
+       {
+       for (i=0;i<elenco.length;i++)
+               {
+                      document.write("<input type=radio name=interp value="+elenco[i]+"> "+labels[i]+"<br />"); 
+               }
+       }
+
+function templateambigpdq2_invia(document,elenco)
+       {
+       stringa=top.topurl+"/searchPattern?term="+top.terminecic;
+       stringa=stringa+"&aliases="+(top.listaliases==""?"":"%20");
+       controllo=stringa.length;
+       for (j=0;j<elenco.length;j++)
+               {
+               if (document.disamb.interp[j].checked)
+                       {
+                       stringa=stringa+escape(elenco[j]);
+
+      // TODO da implementare nella terza fase
+                       //top.aliasglob[top.aliasglob.length]=document.disamb.interp[j].value;
+
+                       //for (k=0;k<top.aliasglob.length;k++){alert(top.aliasglob[k])}
+                       //top.listaliases=top.listaliases+document.disamb.interp[j].value;//in caso di query ulteriori con la stessa lista di alias
+                       }
+                       
+               }
+       if (stringa.length!=controllo) 
+               {
+               window.open(ask_uwobo(stringa),"cw");
+               }
+               else {alert("You must choose one option.");}
+       } 
+
+
+
+// UTILITY FUNCTIONS FOR templateambigpdq3.html
+function templateambigpdq3_init(aliases)
+{
+   top.aliasglob = new Array();
+   for (i=0; i<aliases.length; i++) {
+      top.aliasglob[i] = aliases[i];
+   }
+   top.vlds=new Array();
+   top.window.open(top.topurl+top.action+"editorpdq.html", "sw");
+}
 </SCRIPT>
 </HEAD>
   <script>
index 3647cddf56eca302c7344aaedb8c4d724aea8dd8..b6b5222e329362b965e0af39da37f9d85d480e68 100644 (file)
@@ -14,7 +14,7 @@ function armageddon()
 function invia()
        {
        top.window.open(top.topurl+top.action+"start.html","qw");
-       top.window.open(top.topurl+"/locate?id="+document.locate.oggetto.value,"bw");
+       top.window.open(top.ask_uwobo(top.topurl+"/locate?id="+document.locate.oggetto.value),"bw");
        }
 </SCRIPT>
 </HEAD>
index d5fa12260c9925f9be81dbb7c8c0c8632545e9be..395283ae3bc24ab178c48378c7377a474f3e8d4e 100644 (file)
@@ -1,80 +1,22 @@
 <HTML>
 <HEAD>
 <TITLE>@TITLE@</TITLE>
+<style> A { text-decoration: none } </style>
 <SCRIPT language="Javascript">
-var ambiguousinput="@MSG@";
-var elenco = new Array(@CHOICES@);
-var id = "@ID@";
-function armageddon()
-       {
-       top.initialize();
-       top.window.open(top.topurl+top.action+"start.html","qw");
-       top.window.open(top.topurl+top.action+"blank.html","cw");
-       top.window.open(top.topurl+top.action+"blank.html","hw");
-       top.window.open(top.topurl+top.action+"blank.html","gw");
-       top.window.open(top.topurl+top.action+"blank.html","sw");
-       }
-function resetta()
-       {
-       if (confirm("This will erase your query and start a new one. Are you sure you want to do this?"))
-               {armageddon();}
-       }
-function listauri()
-       {
-       for (i=0;i<elenco.length;i++)
-               {
-               document.write("<input type=checkbox name=uricheck value="+elenco[i]+"> "+elenco[i]+"<br>"); 
-               }
-       }
-function invia()
-       {
-       vecchiavlds=top.vlds.length;
-       stringa=top.topurl+"/searchPattern?term="+top.terminecic;
-       stringa=stringa+"&aliases="+top.listaliases;
-       stringa=stringa+"&choices=";
-  var choices = "";
-       top.vlds[top.vlds.length]=id;
-       for (j=0;j<elenco.length;j++)
-               {
-               if (document.disamb.uricheck[j].checked)
-                       {
-                       top.vlds[top.vlds.length]=document.disamb.uricheck[j].value;
-                       }
-               }
-       top.vlds[top.vlds.length]=";";
-       for (j=0;j<top.vlds.length;j++)
-               {
-    choices=choices+(top.vlds[j]==";"?";":escape(top.vlds[j]))+" ";
-               //if (j!=top.vlds.length-1) {stringa=stringa+","}
-               }
-       choices=choices.substring(0,choices.length-2);
-  stringa=stringa+escape(choices);
-       if (top.vlds.length==vecchiavlds){alert("You must select at least one of the options.");}
-               else
-               {
-               window.open(stringa,"cw");
-               }
-       } 
-  function selezionaCostanti() {
-    for (i=0; i<elenco.length; i++) {
-      if (elenco[i].substring(elenco[i].length-4, elenco[i].length) != ".var") {
-        document.disamb.uricheck[i].checked = true;
-      } else {
-        document.disamb.uricheck[i].checked = false;
-      }
-    }
-  }
+   var ambiguousinput="@MSG@";
+   var elenco = new Array(@CHOICES@);
+   var ident = "@ID@";
 </SCRIPT>
 </HEAD>
 <BODY>
 <h3><SCRIPT language="Javascript">document.write(ambiguousinput);</SCRIPT></h3>
-<br>Please select one or more of the following.
-<br>
+<br />Please select one or more of the following.
+<br />
 <form name="disamb">
-<SCRIPT language="Javascript">listauri();</SCRIPT><br>
-<input type=button value="Ok" onClick="invia();">
-<input type=button value="Constants Only" onClick="selezionaCostanti();">
-<input type=button value=Cancel onClick="resetta();">
-<form>
+<SCRIPT language="Javascript">top.templateambigpdq1_listauri(document,elenco);</SCRIPT><br />
+<input type="button" value="Ok" onClick="top.templateambigpdq1_invia(document,top,elenco,ident);" />
+<input type="button" value="Constants Only" onClick="top.templateambigpdq1_selezionaCostanti(document,elenco);" />
+<input type="button" value="Cancel" onClick="top.templateambigpdq1_resetta();" />
+</form>
 </BODY>
 </HTML>
index 525e69459527cc8d1a2e29f14dd12aef62bfcb7c..ad58e7f1f7725411104c1a21eb8ba8d7635808f4 100644 (file)
@@ -1,64 +1,19 @@
 <HTML>
 <HEAD>
+<style> A { text-decoration: none } </style>
 <SCRIPT language="Javascript">
-elenco = new Array(@INTERPRETATIONS@);
-labels = new Array(@INTERPRETATIONS_LABELS@);
-function armageddon()
-       {
-       top.initialize();
-       top.window.open(top.topurl+top.action+"start.html","qw");
-       top.window.open(top.topurl+top.action+"blank.html","cw");
-       top.window.open(top.topurl+top.action+"blank.html","hw");
-       top.window.open(top.topurl+top.action+"blank.html","gw");
-       top.window.open(top.topurl+top.action+"blank.html","sw");
-       }
-function resetta()
-       {
-       if (confirm("This will erase your query and start a new one. Are you sure you want to do this?"))
-               {armageddon();}
-       }
-function listainterpretazioni()
-       {
-       for (i=0;i<elenco.length;i++)
-               {
-      document.write("<input type=radio name=interp value="+elenco[i]+"> "+labels[i]+"<br>"); 
-               }
-       }
-function invia()
-       {
-       stringa=top.topurl+"/searchPattern?term="+top.terminecic;
-       stringa=stringa+"&aliases="+(top.listaliases==""?"":"%20");
-       controllo=stringa.length;
-       for (j=0;j<elenco.length;j++)
-               {
-               if (document.disamb.interp[j].checked)
-                       {
-                       stringa=stringa+escape(elenco[j]);
-
-      // TODO da implementare nella terza fase
-                       //top.aliasglob[top.aliasglob.length]=document.disamb.interp[j].value;
-
-                       //for (k=0;k<top.aliasglob.length;k++){alert(top.aliasglob[k])}
-                       //top.listaliases=top.listaliases+document.disamb.interp[j].value;//in caso di query ulteriori con la stessa lista di alias
-                       }
-                       
-               }
-       if (stringa.length!=controllo) 
-               {
-               window.open(stringa,"cw");
-               }
-               else {alert("You must choose one option.");}
-       } 
+   var elenco = new Array(@INTERPRETATIONS@);
+   var labels = new Array(@INTERPRETATIONS_LABELS@);
 </SCRIPT>
 </HEAD>
 <BODY>
 <h3>There are more than one possible interpretations.</h3>
-<br>Please choose one of the following.
-<br>
+<br />Please choose one of the following.
+<br />
 <form name="disamb">
-<SCRIPT language="Javascript">listainterpretazioni();</SCRIPT><br>
-<input type=button value="Ok" onClick="invia();">
-<input type=button value=Cancel onClick="resetta();">
-<form>
+<SCRIPT language="Javascript">top.templateambigpdq2_listainterpretazioni(document,elenco,labels);</SCRIPT><br />
+<input type="button" value="Ok" onClick="top.templateambigpdq2_invia(document,elenco);" />
+<input type="button" value="Cancel" onClick="top.templateambigpdq2_resetta();" />
+</form>
 </BODY>
 </HTML>
index 6a6a17b96771b89afd6dd68cb5bb79ac83a3498a..851326495e3e09c45dd7eecf4362cf8a4c19c516 100644 (file)
@@ -1,16 +1,11 @@
 <html>
-       <head>
-               <script>
-                       aliases = new Array(@NEW_ALIASES@);
-                       top.aliasglob = new Array();
-                       for (i=0; i<aliases.length; i++) {
-                               top.aliasglob[i] = aliases[i];
-                       }
-                       top.vlds=new Array();
-                       top.window.open(top.topurl+top.action+"editorpdq.html", "sw");
-               </script>
-       </head>
-       <body>
-               <pre>@RESULTS@</pre>
-       </body>
+   <head>
+      <style> A { text-decoration: none } </style>
+      <script>
+         top.templateambigpdq3_init(new Array(@NEW_ALIASES@));
+      </script>
+   </head>
+   <body>
+      @RESULTS@
+   </body>
 </html>
index 109baa45c225644db9f5e4ac68239ca22ab6b9bc..9bc3ef2c95eafc12ac2de858bf0a807040ece0ba 100644 (file)
 
 let debug = true;;
 let debug_print s = if debug then prerr_endline s;;
+Http_common.debug := true;;
 (* Http_common.debug := true;; *)
 
+  (** accepted HTTP servers for ask_uwobo method forwarding *)
+let valid_servers = [ "mowgli.cs.unibo.it:58080" ] ;;
+
 open Printf;;
 
 let postgresConnectionString =
@@ -51,12 +55,26 @@ let final_results_TPL = pages_dir ^ "/templateambigpdq3.html";;
 
 exception Chat_unfinished
 
-  (** pretty print a MathQL query result to a string *)
-let text_of_result result sep =
- let res_string = ref "" in
-  let app = function s -> res_string := !res_string ^ s in
-   MQueryUtil.text_of_result app result sep ;
-   !res_string
+  (** pretty print a MathQL query result to an HELM theory file *)
+let theory_of_result result =
+ let results_no = List.length result in
+  if results_no > 0 then
+   let mode = if results_no > 10 then "linkonly" else "typeonly" in
+   let results =
+    let idx = ref (results_no + 1) in
+     List.fold_right
+      (fun (uri,attrs) i ->
+        decr idx ;
+        "<tr><td valign=\"top\">" ^ string_of_int !idx ^ ".</td><td><ht:OBJECT uri=\"" ^ uri ^ "\" mode=\"" ^ mode ^ "\"/></td></tr>" ^  i
+      ) result ""
+   in
+    "<h1>Query Results:</h1><table xmlns:ht=\"http://www.cs.unibo.it/helm/namespaces/helm-theory\">" ^ results ^ "</table>"
+  else
+    "<h1>Query Results:</h1><p>No results found!</p>"
+;;
+
+let pp_result result =
+ "<html xmlns:ht=\"http://www.cs.unibo.it/helm/namespaces/helm-theory\">\n<head><title>Query Results</title><style> A { text-decoration: none } </style></head>\n<body>" ^ theory_of_result result ^ "</body></html>"
 ;;
 
   (** chain application of Pcre substitutions *)
@@ -85,6 +103,7 @@ let (title_tag_RE, choices_tag_RE, msg_tag_RE, id_to_uris_RE, id_RE,
   Pcre.regexp "@ID_TO_URIS@", Pcre.regexp "@ID@",
   Pcre.regexp "@INTERPRETATIONS@", Pcre.regexp "@INTERPRETATIONS_LABELS@",
   Pcre.regexp "@RESULTS@", Pcre.regexp "@NEW_ALIASES@")
+let server_and_port_url_RE = Pcre.regexp "^http://([^/]+)/.*$"
 
 let port =
   try
@@ -95,11 +114,6 @@ let port =
       prerr_endline "Warning: invalid port, reverting to default";
       default_port
 in
-let pp_result result =
- let res_string = text_of_result result "\n" in
-  (sprintf "<html>\n<head>\n</head>\n<body>\n<pre>%s</pre>\n</body>\n</html>"
-    res_string)
-in
 let pp_error = sprintf "<html><body><h1>Error: %s</h1></body></html>" in
 let bad_request body outchan =
   Http_daemon.respond_error ~status:(`Client_error `Bad_request) ~body outchan
@@ -123,11 +137,8 @@ let callback (req: Http_types.request) outchan =
         let lexbuf = Lexing.from_string query_string in
         let query = MQueryUtil.query_of_text lexbuf in
         let result = MQueryGenerator.execute_query query in
-        let result_string = text_of_result result "\n" in
-        Http_daemon.respond
-          ~body:
-            (sprintf "<html><body><pre>%s</pre></body></html>" result_string)
-          ~headers:[contype] outchan
+        let result_string = pp_result result in
+        Http_daemon.respond ~body:result_string ~headers:[contype] outchan
     | "/locate" ->
         let id = req#param "id" in
         let result = MQueryGenerator.locate id in
@@ -142,6 +153,19 @@ let callback (req: Http_types.request) outchan =
             Http_daemon.respond_file
               ~fname:(sprintf "%s/%s" pages_dir (remove_fragment page)) outchan
         | page -> Http_daemon.respond_forbidden ~url:page outchan)
+    | "/ask_uwobo" ->
+      let url = req#param "url" in
+      let server_and_port =
+        (Pcre.extract ~rex:server_and_port_url_RE url).(1)
+      in
+      if List.mem server_and_port valid_servers then
+        Http_daemon.respond
+          ~body:(Http_client.Convenience.http_get url)
+          outchan
+      else
+        Http_daemon.respond
+          ~body:(pp_error ("Invalid UWOBO server: " ^ server_and_port))
+          outchan
     | "/searchPattern" ->
         let term_string = req#param "term" in
         let lexbuf = Lexing.from_string term_string in
@@ -174,6 +198,8 @@ let callback (req: Http_types.request) outchan =
               | ""::id::tail
               | id::tail when id<>"" ->
                   (fun id' ->
+prerr_endline ("#### " ^ id ^ " :=");
+List.iter (fun u -> prerr_endline ("<" ^ Netencoding.Url.decode u ^ ">")) tail;
                     if id = id' then
                       Some (List.map (fun u -> Netencoding.Url.decode u) tail)
                     else
@@ -213,6 +239,8 @@ let callback (req: Http_types.request) outchan =
                   (match selection_mode with
                   | `SINGLE -> assert false
                   | `EXTENDED ->
+                      Http_daemon.send_basic_headers ~code:200 outchan ;
+                      Http_daemon.send_CRLF outchan ;
                       iter_file
                         (fun line ->
                           let formatted_choices =
@@ -228,7 +256,7 @@ let callback (req: Http_types.request) outchan =
                                id_RE, id]
                               line
                           in
-                          output_string outchan processed_line)
+                          output_string outchan (processed_line ^ "\n"))
                         interactive_user_uri_choice_TPL;
                       raise Chat_unfinished))
 
@@ -262,6 +290,8 @@ let callback (req: Http_types.request) outchan =
                       "\"")
                     interpretations)
               in
+              Http_daemon.send_basic_headers ~code:200 outchan ;
+              Http_daemon.send_CRLF outchan ;
               iter_file
                 (fun line ->
                   let processed_line =
@@ -270,7 +300,7 @@ let callback (req: Http_types.request) outchan =
                        interpretations_labels_RE, html_interpretations_labels]
                       line
                   in
-                  output_string outchan processed_line)
+                  output_string outchan (processed_line ^ "\n"))
                 interactive_interpretation_choice_TPL;
               raise Chat_unfinished
 
@@ -289,6 +319,8 @@ let callback (req: Http_types.request) outchan =
             let must = MQueryLevels2.get_constraints term' in
             let must',only = refine_constraints must in
             let results = MQueryGenerator.searchPattern must' only in 
+            Http_daemon.send_basic_headers ~code:200 outchan ;
+            Http_daemon.send_CRLF outchan ;
             iter_file
               (fun line ->
                 let new_aliases =
@@ -311,11 +343,11 @@ let callback (req: Http_types.request) outchan =
                 in
                 let processed_line =
                   apply_substs
-                    [results_RE, text_of_result results "\n";
+                    [results_RE, theory_of_result results ;
                      new_aliases_RE, new_aliases]
                     line
                 in
-                output_string outchan processed_line)
+                output_string outchan (processed_line ^ "\n"))
               final_results_TPL
         | _ -> (* unable to instantiate some implicit variable *)
             Http_daemon.respond