let resource_type = resource_type_of_url url in
let extension = extension_of_resource_type resource_type in
let downloadname =
let resource_type = resource_type_of_url url in
let extension = extension_of_resource_type resource_type in
let downloadname =
- 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
+ Some (Http_getter_common.patch_xml ?xmlbases ~via_http ())
+ else
+ None
- if not (is_in_cache basename) then begin (* cache MISS *)
+ if local_resource then begin (* resource available via file system *)
+ Http_getter_logger.log ~level:2 "Local resource, avoid caching";
+ None
+ end else if not (is_in_cache basename) then begin (* 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
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
Http_getter_logger.log ~level:2 "Cache HIT :-)";
None
end
)) in
let tmp_short_circuit = fill_cache () in
threadSafe#doReader (lazy(
Http_getter_logger.log ~level:2 "Cache HIT :-)";
None
end
)) in
let tmp_short_circuit = fill_cache () in
threadSafe#doReader (lazy(
- assert (is_in_cache basename);
- match (enc, Lazy.force Http_getter_env.cache_mode) with
+ assert (local_resource || is_in_cache basename);
+ let basename = match local_part with Some f -> f | None -> basename in
+ let resource_type =
+ if local_resource then
+ resource_type
+ else
+ Lazy.force Http_getter_env.cache_mode
+ in
+ match (enc, resource_type) with
| `Gzipped ->
Http_getter_logger.log ~level:2
"No format mangling required (encoding = gzipped)";
return_file
~via_http ~fname:(basename ^ ".gz") ~contype ~contenc:"x-gzip"
| `Gzipped ->
Http_getter_logger.log ~level:2
"No format mangling required (encoding = gzipped)";
return_file
~via_http ~fname:(basename ^ ".gz") ~contype ~contenc:"x-gzip"
outchan)
| `Normal, `Gzipped | `Gzipped, `Normal ->
(match tmp_short_circuit with
| None -> (* no short circuit possible, use cache *)
Http_getter_logger.log ~level:2
outchan)
| `Normal, `Gzipped | `Gzipped, `Normal ->
(match tmp_short_circuit with
| None -> (* no short circuit possible, use cache *)
Http_getter_logger.log ~level:2
| `Gzipped ->
(* required format is gzipped, cached version is normal *)
gzip ~output:tmp ~keep:true basename; (* gzip to tmp *)
return_file
~via_http ~fname:tmp ~contype ~contenc:"x-gzip"
| `Gzipped ->
(* required format is gzipped, cached version is normal *)
gzip ~output:tmp ~keep:true basename; (* gzip to tmp *)
return_file
~via_http ~fname:tmp ~contype ~contenc:"x-gzip"
outchan)
))
| Some (fname, `Normal) -> (* short circuit available, use it! *)
Http_getter_logger.log ~level:2
"Using short circuit (encoding = normal)";
finally (fun () -> Sys.remove fname) (lazy (
outchan)
))
| Some (fname, `Normal) -> (* short circuit available, use it! *)
Http_getter_logger.log ~level:2
"Using short circuit (encoding = normal)";
finally (fun () -> Sys.remove fname) (lazy (
))
| Some (fname, `Gzipped) -> (* short circuit available, use it! *)
Http_getter_logger.log ~level:2
"Using short circuit (encoding = gzipped)";
finally (fun () -> Sys.remove fname) (lazy (
))
| Some (fname, `Gzipped) -> (* short circuit available, use it! *)
Http_getter_logger.log ~level:2
"Using short circuit (encoding = gzipped)";
finally (fun () -> Sys.remove fname) (lazy (