let version = Http_getter_const.version
-let blanks_RE = Pcre.regexp "\\s"
+let prefix_RE = Pcre.regexp "^\\s*([^\\s]+)\\s+([^\\s]+)\\s*$"
let cache_dir = lazy (normalize_dir (Helm_registry.get "getter.cache_dir"))
let dtd_dir = lazy (normalize_dir (Helm_registry.get "getter.dtd_dir"))
let prefixes = Helm_registry.get_list Helm_registry.string "getter.prefix" in
List.fold_left
(fun acc prefix ->
- match Pcre.split ~rex:blanks_RE prefix with
- | [uri_prefix; url_prefix] -> (uri_prefix, url_prefix) :: acc
- | _ ->
- Http_getter_logger.log ("skipping invalid prefix: " ^ prefix);
- acc)
+ let subs = Pcre.extract ~rex:prefix_RE prefix in
+ try
+ (subs.(1), subs.(2)) :: acc
+ with Invalid_argument _ ->
+ Http_getter_logger.log ("skipping invalid prefix: " ^ prefix);
+ acc)
[] prefixes)
-let host =
- lazy
- (let buf = Buffer.create 20 in
- Shell.call ~stdout:(Shell.to_buffer buf) [Shell.cmd "hostname" ["-f"]];
- Pcre.replace ~pat:"\n+$" (Buffer.contents buf))
+let host = lazy (Http_getter_misc.backtick "hostname -f")
let my_own_url =
lazy
host (if port = 80 then "" else (sprintf ":%d" port)))
let env_to_string () =
- let pp_prefix (uri_prefix, url_prefix) = uri_prefix ^ " -> " ^ url_prefix in
+ let pp_prefix (uri_prefix, url_prefix) =
+ " " ^ uri_prefix ^ " -- " ^ url_prefix
+ in
let pp_prefixes prefixes =
match prefixes with
| [] -> ""
- | l -> "\n" ^ String.concat "\n" (List.map pp_prefix l) ^ "\n"
+ | l -> "\n" ^ String.concat "\n" (List.map pp_prefix l)
in
sprintf
"HTTP Getter %s