clients, uwobo (java implementation, not yet tested with the OCaml one)
starts looping sending output to one of the client *)
-open Http_getter_common;;
-open Http_getter_debugger;;
-open Http_getter_misc;;
-open Http_getter_types;;
-open Printf;;
+open Http_getter_common
+open Http_getter_misc
+open Http_getter_types
+open Printf
(* expose ThreadSafe.threadSafe methods *)
class threadSafe =
(Lazy.force Http_getter_env.rdf_dir) escaped_prefix baseuri extension
in
let patch_fun =
- if patch then Http_getter_common.patch_xml ~via_http () else (fun x -> x)
+ let xmlbases =
+ if Http_getter_common.is_theory_uri uri then
+ Some (Filename.dirname uri, Filename.dirname url)
+ else
+ None
+ in
+ if patch then
+ Http_getter_common.patch_xml ?xmlbases ~via_http ()
+ else
+ (fun x -> x)
in
let basename = Pcre.replace ~pat:"\\.gz$" downloadname in
let contype = "text/xml" in
let fill_cache () =
threadSafe#doWriter (lazy(
if not (is_in_cache basename) then begin (* cache MISS *)
- debug_print "Cache MISS :-(";
+ Http_getter_logger.log ~level:2 "Cache MISS :-(";
mkdir ~parents:true (Filename.dirname downloadname);
match (resource_type, Lazy.force Http_getter_env.cache_mode) with
| `Normal, `Normal | `Gzipped, `Gzipped ->
res
));
end else begin
- debug_print "Cache HIT :-)";
+ Http_getter_logger.log ~level:2 "Cache HIT :-)";
None
end
)) in
(* resource in cache is already in the required format *)
(match enc with
| `Normal ->
- debug_print "No format mangling required (encoding = normal)";
+ Http_getter_logger.log ~level:2
+ "No format mangling required (encoding = normal)";
return_file ~via_http ~fname:basename ~contype ~patch_fun outchan
| `Gzipped ->
- debug_print "No format mangling required (encoding = gzipped)";
+ Http_getter_logger.log ~level:2
+ "No format mangling required (encoding = gzipped)";
return_file
~via_http ~fname:(basename ^ ".gz") ~contype ~contenc:"x-gzip"
~patch_fun ~gunzip:true
| `Normal, `Gzipped | `Gzipped, `Normal ->
(match tmp_short_circuit with
| None -> (* no short circuit possible, use cache *)
- debug_print "No short circuit available, use cache";
+ Http_getter_logger.log ~level:2
+ "No short circuit available, use cache";
let tmp = tempfile () in
finally (fun () -> Sys.remove tmp) (lazy (
(match enc with
outchan)
))
| Some (fname, `Normal) -> (* short circuit available, use it! *)
- debug_print "Using short circuit (encoding = normal)";
+ Http_getter_logger.log ~level:2
+ "Using short circuit (encoding = normal)";
finally (fun () -> Sys.remove fname) (lazy (
return_file ~via_http ~fname ~contype ~patch_fun outchan
))
| Some (fname, `Gzipped) -> (* short circuit available, use it! *)
- debug_print "Using short circuit (encoding = gzipped)";
+ Http_getter_logger.log ~level:2
+ "Using short circuit (encoding = gzipped)";
finally (fun () -> Sys.remove fname) (lazy (
return_file ~via_http ~fname ~contype ~contenc:"x-gzip" ~patch_fun
~gunzip:true outchan