From 617285cac8aabbe62699d5d7144b0df4f5771000 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Wed, 15 Jun 2005 13:35:49 +0000 Subject: [PATCH] renamed clientHTTP to http_getter_wget --- helm/ocaml/getter/.depend | 20 ++++----- helm/ocaml/getter/Makefile | 25 +++++------ helm/ocaml/getter/http_getter.ml | 30 +++++++------ helm/ocaml/getter/http_getter_types.ml | 1 + .../{clientHTTP.ml => http_getter_wget.ml} | 42 ++++++++----------- .../{clientHTTP.mli => http_getter_wget.mli} | 13 +++--- 6 files changed, 66 insertions(+), 65 deletions(-) rename helm/ocaml/getter/{clientHTTP.ml => http_getter_wget.ml} (67%) rename helm/ocaml/getter/{clientHTTP.mli => http_getter_wget.mli} (80%) diff --git a/helm/ocaml/getter/.depend b/helm/ocaml/getter/.depend index d620a3c9a..141c2a88c 100644 --- a/helm/ocaml/getter/.depend +++ b/helm/ocaml/getter/.depend @@ -4,8 +4,8 @@ http_getter_cache.cmi: http_getter_types.cmo http_getter.cmi: http_getter_types.cmo tree.cmo: tree.cmi tree.cmx: tree.cmi -clientHTTP.cmo: clientHTTP.cmi -clientHTTP.cmx: clientHTTP.cmi +http_getter_wget.cmo: http_getter_types.cmo http_getter_wget.cmi +http_getter_wget.cmx: http_getter_types.cmx http_getter_wget.cmi http_getter_logger.cmo: http_getter_logger.cmi http_getter_logger.cmx: http_getter_logger.cmi http_getter_misc.cmo: http_getter_logger.cmi http_getter_misc.cmi @@ -32,11 +32,11 @@ http_getter_cache.cmo: http_getter_types.cmo http_getter_misc.cmi \ http_getter_cache.cmx: http_getter_types.cmx http_getter_misc.cmx \ http_getter_logger.cmx http_getter_env.cmx http_getter_common.cmx \ http_getter_cache.cmi -http_getter.cmo: tree.cmi http_getter_types.cmo http_getter_misc.cmi \ - http_getter_md5.cmi http_getter_map.cmi http_getter_logger.cmi \ - http_getter_env.cmi http_getter_const.cmi http_getter_common.cmi \ - http_getter_cache.cmi clientHTTP.cmi http_getter.cmi -http_getter.cmx: tree.cmx http_getter_types.cmx http_getter_misc.cmx \ - http_getter_md5.cmx http_getter_map.cmx http_getter_logger.cmx \ - http_getter_env.cmx http_getter_const.cmx http_getter_common.cmx \ - http_getter_cache.cmx clientHTTP.cmx http_getter.cmi +http_getter.cmo: tree.cmi http_getter_wget.cmi http_getter_types.cmo \ + http_getter_misc.cmi http_getter_md5.cmi http_getter_map.cmi \ + http_getter_logger.cmi http_getter_env.cmi http_getter_const.cmi \ + http_getter_common.cmi http_getter_cache.cmi http_getter.cmi +http_getter.cmx: tree.cmx http_getter_wget.cmx http_getter_types.cmx \ + http_getter_misc.cmx http_getter_md5.cmx http_getter_map.cmx \ + http_getter_logger.cmx http_getter_env.cmx http_getter_const.cmx \ + http_getter_common.cmx http_getter_cache.cmx http_getter.cmi diff --git a/helm/ocaml/getter/Makefile b/helm/ocaml/getter/Makefile index 2895f12e1..d90461131 100644 --- a/helm/ocaml/getter/Makefile +++ b/helm/ocaml/getter/Makefile @@ -5,18 +5,19 @@ REQUIRES = \ http dbm pcre shell zip \ helm-xml helm-thread helm-logger helm-urimanager helm-registry -INTERFACE_FILES = \ - tree.mli \ - clientHTTP.mli \ - http_getter_logger.mli \ - http_getter_misc.mli \ - http_getter_const.mli \ - http_getter_env.mli \ - http_getter_md5.mli \ - http_getter_common.mli \ - http_getter_map.mli \ - http_getter_cache.mli \ - http_getter.mli +INTERFACE_FILES = \ + tree.mli \ + http_getter_wget.mli \ + http_getter_logger.mli \ + http_getter_misc.mli \ + http_getter_const.mli \ + http_getter_env.mli \ + http_getter_md5.mli \ + http_getter_common.mli \ + http_getter_map.mli \ + http_getter_cache.mli \ + http_getter.mli \ + $(NULL) IMPLEMENTATION_FILES = \ http_getter_types.ml \ diff --git a/helm/ocaml/getter/http_getter.ml b/helm/ocaml/getter/http_getter.ml index 41d62fb38..a4bbb1172 100644 --- a/helm/ocaml/getter/http_getter.ml +++ b/helm/ocaml/getter/http_getter.ml @@ -42,17 +42,18 @@ type resolve_result = type logger_callback = HelmLogger.html_tag -> unit -let stdout_logger tag = print_string (HelmLogger.string_of_html_tag tag) +let stdout_logger tag = print_string (HelmLogger.string_of_html_tag tag) let not_implemented s = raise (Not_implemented ("Http_getter." ^ s)) -let (index_line_sep_RE, index_sep_RE, trailing_types_RE, - heading_cic_RE, heading_theory_RE, heading_nuprl_RE, - heading_rdf_cic_RE, heading_rdf_theory_RE) = - (Pcre.regexp "[ \t]+", Pcre.regexp "\r\n|\r|\n", - Pcre.regexp "\\.types$", - Pcre.regexp "^cic:", Pcre.regexp "^theory:", Pcre.regexp "^nuprl:", - Pcre.regexp "^helm:rdf.*//cic:", Pcre.regexp "^helm:rdf.*//theory:") +let index_line_sep_RE = Pcre.regexp "[ \t]+" +let index_sep_RE = Pcre.regexp "\r\n|\r|\n" +let trailing_types_RE = Pcre.regexp "\\.types$" +let heading_cic_RE = Pcre.regexp "^cic:" +let heading_theory_RE = Pcre.regexp "^theory:" +let heading_nuprl_RE, = Pcre.regexp "^nuprl:" +let heading_rdf_cic_RE = Pcre.regexp "^helm:rdf.*//cic:" +let heading_rdf_theory_RE = Pcre.regexp "^helm:rdf.*//theory:" (* global maps, shared by all threads *) @@ -258,7 +259,9 @@ let ls_remote lsuri = not_implemented "ls_remote" let resolve_remote uri = (* deliver resolve request to http_getter *) - let doc = ClientHTTP.get (sprintf "%sresolve?uri=%s" (getter_url ()) uri) in + let doc = + Http_getter_wget.get (sprintf "%sresolve?uri=%s" (getter_url ()) uri) + in let res = ref Unknown in let start_element tag attrs = match tag with @@ -283,13 +286,14 @@ let resolve_remote uri = | Resolved url -> url let register_remote ~uri ~url = - ClientHTTP.send (sprintf "%sregister?uri=%s&url=%s" (getter_url ()) uri url) + Http_getter_wget.send + (sprintf "%sregister?uri=%s&url=%s" (getter_url ()) uri url) let unregister_remote uri = - ClientHTTP.send (sprintf "%sunregister?uri=%s" (getter_url ()) uri) + Http_getter_wget.send (sprintf "%sunregister?uri=%s" (getter_url ()) uri) let update_remote logger () = - let answer = ClientHTTP.get (getter_url () ^ "update") in + let answer = Http_getter_wget.get (getter_url () ^ "update") in logger (`T answer); logger `BR @@ -300,7 +304,7 @@ let getxml_remote ~format ~patch_dtd uri = (match format with `Normal -> "normal" | `Gzipped -> "gz") (match patch_dtd with true -> "yes" | false -> "no") in - ClientHTTP.get_and_save_to_tmp uri + Http_getter_wget.get_and_save_to_tmp uri (* API *) diff --git a/helm/ocaml/getter/http_getter_types.ml b/helm/ocaml/getter/http_getter_types.ml index e8e31bd0f..1574e2bdb 100644 --- a/helm/ocaml/getter/http_getter_types.ml +++ b/helm/ocaml/getter/http_getter_types.ml @@ -36,6 +36,7 @@ exception Cache_failure of string exception Dtd_not_found of string (* dtd's url *) exception Key_already_in of string;; exception Key_not_found of string;; +exception Http_client_error of string * string (* url, error message *) type encoding = [ `Normal | `Gzipped ] type answer_format = [ `Text | `Xml ] diff --git a/helm/ocaml/getter/clientHTTP.ml b/helm/ocaml/getter/http_getter_wget.ml similarity index 67% rename from helm/ocaml/getter/clientHTTP.ml rename to helm/ocaml/getter/http_getter_wget.ml index b4e0e26b6..99a9f01e7 100644 --- a/helm/ocaml/getter/clientHTTP.ml +++ b/helm/ocaml/getter/http_getter_wget.ml @@ -1,4 +1,4 @@ -(* Copyright (C) 2000, HELM Team. +(* Copyright (C) 2000-2005, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science @@ -23,41 +23,35 @@ * http://cs.unibo.it/helm/. *) -exception HttpClientError of string * string;; (* reason, uri *) +open Http_getter_types let send cmd = - try - ignore (Http_user_agent.get cmd) - with - e -> raise (HttpClientError (Printexc.to_string e, cmd)) -;; + try + ignore (Http_user_agent.get cmd) + with e -> raise (Http_client_error (cmd, Printexc.to_string e)) let get uri = - try - Http_user_agent.get uri - with - e -> raise (HttpClientError (Printexc.to_string e, uri)) -;; + try + Http_user_agent.get uri + with e -> raise (Http_client_error (Printexc.to_string e, uri)) let get_and_save uri dest_filename = - let out_channel = open_out dest_filename in - Http_user_agent.get_iter (output_string out_channel) uri; - close_out out_channel -;; + let out_channel = open_out dest_filename in + Http_user_agent.get_iter (output_string out_channel) uri; + close_out out_channel let get_and_save_to_tmp uri = - let flat_string s s' c = - let cs = String.copy s in - for i = 0 to (String.length s) - 1 do - if String.contains s' s.[i] then cs.[i] <- c - done ; - cs - in + let flat_string s s' c = + let cs = String.copy s in + for i = 0 to (String.length s) - 1 do + if String.contains s' s.[i] then cs.[i] <- c + done ; + cs + in let user = try Unix.getlogin () with _ -> "" in let tmp_file = Filename.temp_file (user ^ flat_string uri ".-=:;!?/&" '_') "" in get_and_save uri tmp_file ; tmp_file -;; diff --git a/helm/ocaml/getter/clientHTTP.mli b/helm/ocaml/getter/http_getter_wget.mli similarity index 80% rename from helm/ocaml/getter/clientHTTP.mli rename to helm/ocaml/getter/http_getter_wget.mli index f45d63dda..4c978314e 100644 --- a/helm/ocaml/getter/clientHTTP.mli +++ b/helm/ocaml/getter/http_getter_wget.mli @@ -1,4 +1,4 @@ -(* Copyright (C) 2000, HELM Team. +(* Copyright (C) 2000-2005, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science @@ -23,8 +23,9 @@ * http://cs.unibo.it/helm/. *) -exception HttpClientError of string * string;; (* reason, uri *) -val send : string -> unit -val get : string -> string -val get_and_save : string -> string -> unit -val get_and_save_to_tmp : string -> string +val send: string -> unit + +val get: string -> string +val get_and_save: string -> string -> unit +val get_and_save_to_tmp: string -> string + -- 2.39.2