+let build_dynamic_uri url params =
+ let p =
+ String.concat "&" (List.map (fun (key,value) -> (key ^ "=" ^ (Netencoding.Url.encode value))) params) in
+ url ^ "?" ^ p
+in
+
+let build_uwobo_request (req: Http_types.request) outchan =
+ prerr_endline ("ECCOLO: " ^ req#param "param.SEARCH_ENGINE_URL");
+ let xmluri = build_dynamic_uri ((req#param "param.SEARCH_ENGINE_URL") ^ "/search") req#params in
+ prerr_endline ("xmluri: " ^ xmluri);
+ (*let xmluri = Netencoding.Url.encode xmluri in*)
+ let server_and_port = req#param "param.processorURL" in
+ let newreq =
+ build_dynamic_uri
+ (server_and_port ^ "apply")
+ (("xmluri",xmluri)::("keys",(req#param "param.thkeys"))::req#params) in
+ (* if List.mem server_and_port valid_servers then *)
+ prerr_endline newreq;
+ if true then
+ Http_daemon.respond
+ ~headers:["Content-Type", "text/html"]
+ ~body:(Http_client.http_get newreq)
+ outchan
+ else
+ Http_daemon.respond
+ ~body:(pp_error ("Untrusted UWOBO server: " ^ server_and_port ^
+ (String.concat "\n" valid_servers)))
+ outchan
+in
+
+let proxy url outchan =
+ 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
+ ~headers:["Content-Type", "text/html"]
+ ~body:(Http_client.http_get url)
+ outchan
+ else
+ Http_daemon.respond
+ ~body:(pp_error ("Untrusted UWOBO server: " ^ server_and_port))
+ outchan
+in
+