From 6a8da4dd52033adfe80533f7467439aec1561147 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 14 Nov 2002 11:57:58 +0000 Subject: [PATCH] no longer use -pack and Http.*, now interface is the usual Http_* --- helm/DEVEL/ocaml-http/.depend | 31 ++-- helm/DEVEL/ocaml-http/Makefile | 18 +-- helm/DEVEL/ocaml-http/Makefile.defs | 2 +- helm/DEVEL/ocaml-http/debian/changelog | 7 + helm/DEVEL/ocaml-http/examples/Makefile | 2 +- .../ocaml-http/examples/always_ok_daemon.ml | 6 +- helm/DEVEL/ocaml-http/examples/dump_args.ml | 12 +- helm/DEVEL/ocaml-http/examples/obj_foo.ml | 4 +- helm/DEVEL/ocaml-http/examples/timeout.ml | 2 +- helm/DEVEL/ocaml-http/examples/webfsd.ml | 2 +- .../ocaml-http/{common.ml => http_common.ml} | 2 +- .../{common.mli => http_common.mli} | 14 +- .../ocaml-http/{daemon.ml => http_daemon.ml} | 52 ++++--- .../{daemon.mli => http_daemon.mli} | 23 +-- .../ocaml-http/{misc.ml => http_misc.ml} | 0 .../ocaml-http/{misc.mli => http_misc.mli} | 0 .../{request.ml => http_request.ml} | 2 +- .../{request.mli => http_request.mli} | 3 +- .../{response.ml => http_response.ml} | 10 +- .../{response.mli => http_response.mli} | 2 +- .../ocaml-http/{types.ml => http_types.ml} | 0 helm/DEVEL/ocaml-http/types.mli | 147 ------------------ 22 files changed, 103 insertions(+), 238 deletions(-) rename helm/DEVEL/ocaml-http/{common.ml => http_common.ml} (99%) rename helm/DEVEL/ocaml-http/{common.mli => http_common.mli} (76%) rename helm/DEVEL/ocaml-http/{daemon.ml => http_daemon.ml} (89%) rename helm/DEVEL/ocaml-http/{daemon.mli => http_daemon.mli} (84%) rename helm/DEVEL/ocaml-http/{misc.ml => http_misc.ml} (100%) rename helm/DEVEL/ocaml-http/{misc.mli => http_misc.mli} (100%) rename helm/DEVEL/ocaml-http/{request.ml => http_request.ml} (98%) rename helm/DEVEL/ocaml-http/{request.mli => http_request.mli} (91%) rename helm/DEVEL/ocaml-http/{response.ml => http_response.ml} (95%) rename helm/DEVEL/ocaml-http/{response.mli => http_response.mli} (96%) rename helm/DEVEL/ocaml-http/{types.ml => http_types.ml} (100%) delete mode 100644 helm/DEVEL/ocaml-http/types.mli diff --git a/helm/DEVEL/ocaml-http/.depend b/helm/DEVEL/ocaml-http/.depend index 72d1e0263..528e32d66 100644 --- a/helm/DEVEL/ocaml-http/.depend +++ b/helm/DEVEL/ocaml-http/.depend @@ -1,16 +1,15 @@ -common.cmo: types.cmi common.cmi -common.cmx: types.cmx common.cmi -daemon.cmo: common.cmi misc.cmi request.cmi types.cmi daemon.cmi -daemon.cmx: common.cmx misc.cmx request.cmx types.cmx daemon.cmi -misc.cmo: misc.cmi -misc.cmx: misc.cmi -request.cmo: common.cmi request.cmi -request.cmx: common.cmx request.cmi -response.cmo: common.cmi daemon.cmi types.cmi response.cmi -response.cmx: common.cmx daemon.cmx types.cmx response.cmi -types.cmo: types.cmi -types.cmx: types.cmi -common.cmi: types.cmi -daemon.cmi: types.cmi -request.cmi: types.cmi -response.cmi: types.cmi +http_common.cmo: http_types.cmi http_common.cmi +http_common.cmx: http_types.cmx http_common.cmi +http_daemon.cmo: http_common.cmi http_misc.cmi http_request.cmi \ + http_types.cmi http_daemon.cmi +http_daemon.cmx: http_common.cmx http_misc.cmx http_request.cmx \ + http_types.cmx http_daemon.cmi +http_misc.cmo: http_misc.cmi +http_misc.cmx: http_misc.cmi +http_request.cmo: http_common.cmi http_request.cmi +http_request.cmx: http_common.cmx http_request.cmi +http_response.cmo: http_common.cmi http_daemon.cmi http_response.cmi +http_response.cmx: http_common.cmx http_daemon.cmx http_response.cmi +http_types.cmo: http_types.cmi +http_types.cmx: http_types.cmi +http_common.cmi: http_types.cmi diff --git a/helm/DEVEL/ocaml-http/Makefile b/helm/DEVEL/ocaml-http/Makefile index 950c72035..4f4def3fe 100644 --- a/helm/DEVEL/ocaml-http/Makefile +++ b/helm/DEVEL/ocaml-http/Makefile @@ -1,6 +1,7 @@ include Makefile.defs -MODULES = common misc types request daemon response +MODULES = http_common http_misc http_types http_request http_daemon http_response +PUBLIC_MODULES = http_common http_types http_request http_daemon http_response DESTDIR = $(shell $(OCAMLFIND) printconf stdlib) all: http.cma @@ -24,14 +25,10 @@ depend: %.cmx: %.ml %.cmi $(OCAMLOPT) -c $< -http.cmo: $(patsubst %,%.cmo,$(MODULES)) - ocamlc -pack -o $@ $^ -http.cmx: $(patsubst %,%.cmx,$(MODULES)) - ocamlopt -pack -o $@ $^ -http.cma: http.cmo - $(OCAMLC) -a -o $@ $< -http.cmxa: http.cmx - $(OCAMLOPT) -a -o $@ $< +http.cma: $(patsubst %,%.cmo,$(MODULES)) + $(OCAMLC) -a -o $@ $^ +http.cmxa: $(patsubst %,%.cmx,$(MODULES)) + $(OCAMLOPT) -a -o $@ $^ meta: META META: META.in @@ -55,7 +52,8 @@ dist: distclean depend rm -rf $(DISTDIR)/ install: META $(OCAMLFIND) install -destdir $(DESTDIR) $(PKGNAME) \ - META common.mli types.mli request.mli daemon.mli response.mli http.* + META $(patsubst %,%.mli,$(PUBLIC_MODULES)) \ + $(patsubst %,%.cmi,$(PUBLIC_MODULES)) http.cm{,x}a http.a .PHONY: \ all opt world examples examples.opt depend clean distclean dist \ diff --git a/helm/DEVEL/ocaml-http/Makefile.defs b/helm/DEVEL/ocaml-http/Makefile.defs index a22325292..060a57037 100644 --- a/helm/DEVEL/ocaml-http/Makefile.defs +++ b/helm/DEVEL/ocaml-http/Makefile.defs @@ -8,7 +8,7 @@ OCAMLOPT = $(OCAMLFIND) ocamlopt $(COMMON_OPTS) OCAMLDEP = $(OCAMLFIND) ocamldep $(COMMON_OPTS) DISTNAME = ocaml-http -DISTVERSION = 0.0.1 +DISTVERSION = 0.0.2 DISTDIR = $(DISTNAME)-$(DISTVERSION) EXTRA_DIST = INSTALL LICENSE README META.in Makefile Makefile.defs .depend tophttp diff --git a/helm/DEVEL/ocaml-http/debian/changelog b/helm/DEVEL/ocaml-http/debian/changelog index 01fce0df4..7044be84f 100644 --- a/helm/DEVEL/ocaml-http/debian/changelog +++ b/helm/DEVEL/ocaml-http/debian/changelog @@ -1,3 +1,10 @@ +ocaml-http (0.0.2) unstable; urgency=low + + * Doesn't use anymore -pack, library is now accessible as Http_daemon, + Http_response, ... in place of Http.Daemon, Http.Response, ... + + -- Stefano Zacchiroli Thu, 14 Nov 2002 12:51:07 +0100 + ocaml-http (0.0.1) unstable; urgency=low * Initial Release. diff --git a/helm/DEVEL/ocaml-http/examples/Makefile b/helm/DEVEL/ocaml-http/examples/Makefile index 51e5e2f3b..794b64ef4 100644 --- a/helm/DEVEL/ocaml-http/examples/Makefile +++ b/helm/DEVEL/ocaml-http/examples/Makefile @@ -14,4 +14,4 @@ opt: $(patsubst %,%.opt,$(EXAMPLES)) distclean: clean clean: - -rm -f *.cm[ioax] *.o $(EXAMPLES) + -rm -f *.cm[ioax] *.o $(EXAMPLES) $(patsubst %,%.opt,$(EXAMPLES)) diff --git a/helm/DEVEL/ocaml-http/examples/always_ok_daemon.ml b/helm/DEVEL/ocaml-http/examples/always_ok_daemon.ml index 020d4f600..aafe347e7 100644 --- a/helm/DEVEL/ocaml-http/examples/always_ok_daemon.ml +++ b/helm/DEVEL/ocaml-http/examples/always_ok_daemon.ml @@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *) -open Http.Daemon;; -open Http.Response;; +open Http_daemon;; +open Http_response;; (* start an http daemon that alway respond with a 200 status code and an empty content *) -start (fun _ _ -> respond_with (new Http.Response.response)) +start (fun _ _ -> respond_with (new Http_response.response)) diff --git a/helm/DEVEL/ocaml-http/examples/dump_args.ml b/helm/DEVEL/ocaml-http/examples/dump_args.ml index ba8e4f5ce..6f3f60bbb 100644 --- a/helm/DEVEL/ocaml-http/examples/dump_args.ml +++ b/helm/DEVEL/ocaml-http/examples/dump_args.ml @@ -32,18 +32,18 @@ in let callback path args outchan = match path with | "/gone" -> - Http.Daemon.respond_redirect + Http_daemon.respond_redirect ~location:"/foo" ~body:"REDIRECT" ~code:302 outchan | "/error" -> - Http.Daemon.respond_error ~body:"ERROR" ~code:500 outchan + Http_daemon.respond_error ~body:"ERROR" ~code:500 outchan | _ -> begin - Http.Daemon.send_basic_headers ~code:200 outchan; - Http.Daemon.send_CRLF outchan; + Http_daemon.send_basic_headers ~code:200 outchan; + Http_daemon.send_CRLF outchan; output_string outchan (dump_args path args) end in -print_endline "Starting custom Http.Daemon ..."; +print_endline "Starting custom Http_daemon ..."; flush stdout; -Http.Daemon.start ~addr:"127.0.0.1" ~port:9999 callback +Http_daemon.start ~addr:"127.0.0.1" ~port:9999 callback diff --git a/helm/DEVEL/ocaml-http/examples/obj_foo.ml b/helm/DEVEL/ocaml-http/examples/obj_foo.ml index 98e024045..d28c7e4ac 100644 --- a/helm/DEVEL/ocaml-http/examples/obj_foo.ml +++ b/helm/DEVEL/ocaml-http/examples/obj_foo.ml @@ -20,6 +20,6 @@ *) let callback req outchan = - Http.Daemon.respond_error ~body:(req#param "foo") outchan + Http_daemon.respond_error ~body:(req#param "foo") outchan in -Http.Daemon.start' ~addr:"127.0.0.1" ~port:9999 callback +Http_daemon.start' ~addr:"127.0.0.1" ~port:9999 callback diff --git a/helm/DEVEL/ocaml-http/examples/timeout.ml b/helm/DEVEL/ocaml-http/examples/timeout.ml index 56522f52d..261b8ee3a 100644 --- a/helm/DEVEL/ocaml-http/examples/timeout.ml +++ b/helm/DEVEL/ocaml-http/examples/timeout.ml @@ -23,5 +23,5 @@ let callback _ _ outchan = output_string outchan "Here you are!\n"; flush outchan in -Http.Daemon.start ~addr:"127.0.0.1" ~port:9999 ~timeout:(Some 10) callback +Http_daemon.start ~addr:"127.0.0.1" ~port:9999 ~timeout:(Some 10) callback diff --git a/helm/DEVEL/ocaml-http/examples/webfsd.ml b/helm/DEVEL/ocaml-http/examples/webfsd.ml index ef5c1cb07..6babe3dde 100644 --- a/helm/DEVEL/ocaml-http/examples/webfsd.ml +++ b/helm/DEVEL/ocaml-http/examples/webfsd.ml @@ -36,5 +36,5 @@ let argspec = in Arg.parse argspec (fun _ -> ()) ""; Sys.chdir !root; -Http.Daemon.Trivial.start ~addr:!addr ~port:!port () +Http_daemon.Trivial.start ~addr:!addr ~port:!port () diff --git a/helm/DEVEL/ocaml-http/common.ml b/helm/DEVEL/ocaml-http/http_common.ml similarity index 99% rename from helm/DEVEL/ocaml-http/common.ml rename to helm/DEVEL/ocaml-http/http_common.ml index b175d2e38..8e59dbd58 100644 --- a/helm/DEVEL/ocaml-http/common.ml +++ b/helm/DEVEL/ocaml-http/http_common.ml @@ -21,7 +21,7 @@ exception Invalid_HTTP_version of string exception Invalid_code of int -exception Invalid_status of Types.status +exception Invalid_status of Http_types.status let http_version = `HTTP_1_1 diff --git a/helm/DEVEL/ocaml-http/common.mli b/helm/DEVEL/ocaml-http/http_common.mli similarity index 76% rename from helm/DEVEL/ocaml-http/common.mli rename to helm/DEVEL/ocaml-http/http_common.mli index 1b2874837..172e66e5a 100644 --- a/helm/DEVEL/ocaml-http/common.mli +++ b/helm/DEVEL/ocaml-http/http_common.mli @@ -21,18 +21,18 @@ exception Invalid_HTTP_version of string exception Invalid_code of int -exception Invalid_status of Types.status +exception Invalid_status of Http_types.status -val http_version: Types.version +val http_version: Http_types.version -val string_of_version: Types.version -> string -val version_of_string: string -> Types.version +val string_of_version: Http_types.version -> string +val version_of_string: string -> Http_types.version -val status_of_code: int -> Types.status -val code_of_status: [< Types.status] -> int +val status_of_code: int -> Http_types.status +val code_of_status: [< Http_types.status] -> int val reason_phrase_of_code: int -> string -val reason_phrase_of_status: [< Types.status] -> string +val reason_phrase_of_status: [< Http_types.status] -> string val is_informational: int -> bool val is_success: int -> bool diff --git a/helm/DEVEL/ocaml-http/daemon.ml b/helm/DEVEL/ocaml-http/http_daemon.ml similarity index 89% rename from helm/DEVEL/ocaml-http/daemon.ml rename to helm/DEVEL/ocaml-http/http_daemon.ml index 19ba359fe..3fa78b349 100644 --- a/helm/DEVEL/ocaml-http/daemon.ml +++ b/helm/DEVEL/ocaml-http/http_daemon.ml @@ -181,7 +181,7 @@ let get_code_argument func_name = fun ~code ~status -> (match code, status with | Some c, None -> c - | None, Some s -> Common.code_of_status s + | None, Some s -> Http_common.code_of_status s | Some _, Some _ -> failwith (func_name ^ " you must give 'code' or 'status', not both") | None, None -> @@ -192,30 +192,34 @@ let send_status_line' ~version ~code = let status_line = String.concat " " - [ Common.string_of_version version; + [ Http_common.string_of_version version; string_of_int code; - Common.reason_phrase_of_code code ] + Http_common.reason_phrase_of_code code ] in send_raw ~data:(status_line ^ crlf) -let send_status_line ?(version = Common.http_version) ?code ?status outchan = +let send_status_line + ?(version = Http_common.http_version) ?code ?status outchan + = send_status_line' ~version ~code:(get_code_argument "Daemon.send_status_line" ~code ~status) outchan -let send_basic_headers ?(version = Common.http_version) ?code ?status outchan = +let send_basic_headers + ?(version = Http_common.http_version) ?code ?status outchan + = send_status_line' ~version ~code:(get_code_argument "Daemon.send_basic_headers" ~code ~status) outchan; send_headers - ~headers:["Date", Misc.date_822 (); "Server", "OCaml HTTP Daemon"] + ~headers:["Date", Http_misc.date_822 (); "Server", "OCaml HTTP Daemon"] outchan (** internal: send a fooish body explaining in HTML form the 'reason phrase' of an HTTP response; body, if given, will be appended to the body *) let send_foo_body ~code ~body = - let reason_phrase = Common.reason_phrase_of_code code in + let reason_phrase = Http_common.reason_phrase_of_code code in let body = sprintf " @@ -236,7 +240,7 @@ let send_foo_body ~code ~body = page *) let send_empty_response f_name ?(is_valid_status = fun _ -> true) ?(headers = []) ~body () = - fun ?(version = Common.http_version) ?code ?status outchan -> + fun ?(version = Http_common.http_version) ?code ?status outchan -> let code = get_code_argument f_name ~code ~status in if not (is_valid_status code) then failwith (sprintf "'%d' isn't a valid status code for %s" code f_name) @@ -255,35 +259,35 @@ let send_empty_response (* TODO sanity tests on location *) let respond_redirect ~location ?body - ?(version = Common.http_version) ?(code = 301) ?status outchan = + ?(version = Http_common.http_version) ?(code = 301) ?status outchan = let code = match status with | None -> code - | Some (s: Types.redirection_status) -> Common.code_of_status s + | Some (s: Http_types.redirection_status) -> Http_common.code_of_status s in send_empty_response - "Daemon.respond_redirect" ~is_valid_status:Common.is_redirection + "Daemon.respond_redirect" ~is_valid_status:Http_common.is_redirection ~headers:["Location", location] ~body () ~version ~code outchan let respond_error ?body - ?(version = Common.http_version) ?(code = 400) ?status outchan = + ?(version = Http_common.http_version) ?(code = 400) ?status outchan = let code = match status with | None -> code - | Some s -> Common.code_of_status s + | Some s -> Http_common.code_of_status s in send_empty_response - "Daemon.respond_error" ~is_valid_status:Common.is_error ~body () + "Daemon.respond_error" ~is_valid_status:Http_common.is_error ~body () ~version ~code outchan -let respond_not_found ~url ?(version = Common.http_version) outchan = +let respond_not_found ~url ?(version = Http_common.http_version) outchan = send_empty_response "Daemon.respond_not_found" ~body:None () ~version ~code:404 outchan -let respond_forbidden ~url ?(version = Common.http_version) outchan = +let respond_forbidden ~url ?(version = Http_common.http_version) outchan = send_empty_response "Daemon.respond_permission_denied" ~body:None () ~version ~code:403 outchan @@ -322,7 +326,7 @@ let send_file ?name ?file outchan = let send_dir_listing ~dir ~name ~path outchan = fprintf outchan "\n%s\n\n" name; let (dirs, files) = - List.partition (fun e -> Misc.is_directory (path ^ e)) (Misc.ls dir) + List.partition (fun e -> Http_misc.is_directory (path ^ e)) (Http_misc.ls dir) in List.iter (fun d -> fprintf outchan "%s/
\n" d d) @@ -333,7 +337,7 @@ let send_dir_listing ~dir ~name ~path outchan = fprintf outchan "\n"; flush outchan -let respond_file ~fname ?(version = Common.http_version) outchan = +let respond_file ~fname ?(version = Http_common.http_version) outchan = (** ASSUMPTION: 'fname' doesn't begin with a "/"; it's relative to the current document root (usually the daemon's cwd) *) let droot = Sys.getcwd () in (* document root *) @@ -342,7 +346,7 @@ let respond_file ~fname ?(version = Common.http_version) outchan = respond_not_found ~url:fname outchan else begin try - if Misc.is_directory path then begin (* file found, is a dir *) + if Http_misc.is_directory path then begin (* file found, is a dir *) let dir = Unix.opendir path in send_basic_headers ~version ~code:200 outchan; send_header "Content-Type" "text/html" outchan; @@ -354,7 +358,7 @@ let respond_file ~fname ?(version = Common.http_version) outchan = send_basic_headers ~version ~code:200 outchan; send_header ~header:"Content-Length" - ~value:(string_of_int (Misc.filesize fname)) + ~value:(string_of_int (Http_misc.filesize fname)) outchan; send_CRLF outchan; send_file ~file outchan; @@ -368,7 +372,7 @@ let respond_file ~fname ?(version = Common.http_version) outchan = respond_forbidden ~url:fname ~version outchan end -let respond_with (res: Types.response) outchan = +let respond_with (res: Http_types.response) outchan = res#serialize outchan; flush outchan @@ -431,10 +435,10 @@ let start let start' ?(addr = default_addr) ?(port = default_port) ?(timeout = Some default_timeout) - (callback: (Types.request -> out_channel -> unit)) + (callback: (Http_types.request -> out_channel -> unit)) = let wrapper path params outchan = - let req = new Request.request ~path ~params in + let req = new Http_request.request ~path ~params in callback req outchan in start ~addr ~port ~timeout wrapper @@ -445,7 +449,7 @@ module Trivial = if not (Pcre.pmatch ~rex:(Pcre.regexp "^/") path) then respond_error ~code:400 outchan else - respond_file ~fname:(Misc.strip_heading_slash path) outchan + respond_file ~fname:(Http_misc.strip_heading_slash path) outchan let start ?(addr = default_addr) ?(port = default_port) () = start ~addr ~port callback end diff --git a/helm/DEVEL/ocaml-http/daemon.mli b/helm/DEVEL/ocaml-http/http_daemon.mli similarity index 84% rename from helm/DEVEL/ocaml-http/daemon.mli rename to helm/DEVEL/ocaml-http/http_daemon.mli index c7ffee437..60384b26c 100644 --- a/helm/DEVEL/ocaml-http/daemon.mli +++ b/helm/DEVEL/ocaml-http/http_daemon.mli @@ -27,14 +27,14 @@ val send_CRLF: out_channel -> unit either code or status must be given (not both, not none) which represent the HTTP response code, outchan is the output channel to which send status line *) val send_status_line: - ?version: Types.version -> ?code: int -> ?status: Types.status -> + ?version: Http_types.version -> ?code: int -> ?status: Http_types.status -> out_channel -> unit (** like send_status_line but additionally will also send "Date" and "Server" standard headers *) val send_basic_headers: - ?version: Types.version -> ?code: int -> ?status: Types.status -> + ?version: Http_types.version -> ?code: int -> ?status: Http_types.status -> out_channel -> unit @@ -50,11 +50,11 @@ val send_file: ?name:string -> ?file:in_channel -> out_channel -> unit (** send a 404 (not found) HTTP response *) val respond_not_found: - url:string -> ?version: Types.version -> out_channel -> unit + url:string -> ?version: Http_types.version -> out_channel -> unit (** send a 403 (forbidden) HTTP response *) val respond_forbidden: - url:string -> ?version: Types.version -> out_channel -> unit + url:string -> ?version: Http_types.version -> out_channel -> unit (** send a "redirection" class response, optional body argument contains data that will be displayed in the body of the response, default response status is @@ -62,7 +62,8 @@ val respond_forbidden: function, other values will @raise Failure *) val respond_redirect: location:string -> ?body:string -> - ?version: Types.version -> ?code: int -> ?status: Types.redirection_status -> + ?version: Http_types.version -> + ?code: int -> ?status: Http_types.redirection_status -> out_channel -> unit @@ -72,16 +73,18 @@ val respond_redirect: @raise Failure *) val respond_error: ?body:string -> - ?version: Types.version -> ?code: int -> ?status: Types.error_status -> + ?version: Http_types.version -> + ?code: int -> ?status: Http_types.error_status -> out_channel -> unit (** tipical static pages http daemon behaviour, if requested url is a file, return it, it it is a directory return a directory listing of it *) -val respond_file: fname:string -> ?version: Types.version -> out_channel -> unit +val respond_file: + fname:string -> ?version: Http_types.version -> out_channel -> unit - (** respond using a prebuilt Types.response object *) -val respond_with: Types.response -> out_channel -> unit + (** respond using a prebuilt Http_types.response object *) +val respond_with: Http_types.response -> out_channel -> unit (** create an HTTP daemon listening on 'addr':'port' (defaults are addr:"0.0.0.0" and port:80), callback is the user supplied function which @@ -102,7 +105,7 @@ val start: object *) val start': ?addr: string -> ?port: int -> ?timeout: int option -> - (Types.request -> out_channel -> unit) -> + (Http_types.request -> out_channel -> unit) -> unit (** Trivial static pages HTTP daemon *) diff --git a/helm/DEVEL/ocaml-http/misc.ml b/helm/DEVEL/ocaml-http/http_misc.ml similarity index 100% rename from helm/DEVEL/ocaml-http/misc.ml rename to helm/DEVEL/ocaml-http/http_misc.ml diff --git a/helm/DEVEL/ocaml-http/misc.mli b/helm/DEVEL/ocaml-http/http_misc.mli similarity index 100% rename from helm/DEVEL/ocaml-http/misc.mli rename to helm/DEVEL/ocaml-http/http_misc.mli diff --git a/helm/DEVEL/ocaml-http/request.ml b/helm/DEVEL/ocaml-http/http_request.ml similarity index 98% rename from helm/DEVEL/ocaml-http/request.ml rename to helm/DEVEL/ocaml-http/http_request.ml index 0f5681f7f..91bc98a67 100644 --- a/helm/DEVEL/ocaml-http/request.ml +++ b/helm/DEVEL/ocaml-http/http_request.ml @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *) -open Common;; +open Http_common;; exception Param_not_found of string diff --git a/helm/DEVEL/ocaml-http/request.mli b/helm/DEVEL/ocaml-http/http_request.mli similarity index 91% rename from helm/DEVEL/ocaml-http/request.mli rename to helm/DEVEL/ocaml-http/http_request.mli index 9f2e93656..e8632c4f8 100644 --- a/helm/DEVEL/ocaml-http/request.mli +++ b/helm/DEVEL/ocaml-http/http_request.mli @@ -22,5 +22,6 @@ exception Param_not_found of string (** fooish class to enclose callback's arguments *) -class request: path: string -> params: (string * string) list -> Types.request +class request: + path: string -> params: (string * string) list -> Http_types.request diff --git a/helm/DEVEL/ocaml-http/response.ml b/helm/DEVEL/ocaml-http/http_response.ml similarity index 95% rename from helm/DEVEL/ocaml-http/response.ml rename to helm/DEVEL/ocaml-http/http_response.ml index caad5ab56..b71d887fc 100644 --- a/helm/DEVEL/ocaml-http/response.ml +++ b/helm/DEVEL/ocaml-http/http_response.ml @@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *) -open Common;; -open Daemon;; +open Http_common;; +open Http_daemon;; exception Invalid_status_line of string exception Header_not_found of string @@ -39,7 +39,7 @@ class response = (* "version code reason_phrase" *) let status_line_re = Pcre.regexp "^(HTTP/\d\.\d) (\d{3}) (.*)$" in object (self) - val mutable version = Common.http_version + val mutable version = Http_common.http_version val mutable code = default_code val mutable reason: string option = None val contentsBuf = Buffer.create 1024 val headers = Hashtbl.create 11 @@ -50,7 +50,7 @@ class response = method code = code method setCode c = code <- c method status = status_of_code code - method setStatus (s: Types.status) = code <- code_of_status s + method setStatus (s: Http_types.status) = code <- code_of_status s method reason = match reason with | None -> reason_phrase_of_code code @@ -63,7 +63,7 @@ class response = method setStatusLine s = try let subs = Pcre.extract ~rex:status_line_re s in - self#setVersion (Common.version_of_string subs.(1)); + self#setVersion (Http_common.version_of_string subs.(1)); self#setCode (int_of_string subs.(2)); self#setReason subs.(3) with Not_found -> diff --git a/helm/DEVEL/ocaml-http/response.mli b/helm/DEVEL/ocaml-http/http_response.mli similarity index 96% rename from helm/DEVEL/ocaml-http/response.mli rename to helm/DEVEL/ocaml-http/http_response.mli index 84011aaba..ec0a58eed 100644 --- a/helm/DEVEL/ocaml-http/response.mli +++ b/helm/DEVEL/ocaml-http/http_response.mli @@ -21,5 +21,5 @@ exception Invalid_status_line of string -class response: Types.response +class response: Http_types.response diff --git a/helm/DEVEL/ocaml-http/types.ml b/helm/DEVEL/ocaml-http/http_types.ml similarity index 100% rename from helm/DEVEL/ocaml-http/types.ml rename to helm/DEVEL/ocaml-http/http_types.ml diff --git a/helm/DEVEL/ocaml-http/types.mli b/helm/DEVEL/ocaml-http/types.mli deleted file mode 100644 index aac630960..000000000 --- a/helm/DEVEL/ocaml-http/types.mli +++ /dev/null @@ -1,147 +0,0 @@ - -(* - OCaml HTTP - do it yourself (fully OCaml) HTTP daemon - - Copyright (C) <2002> Stefano Zacchiroli - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*) - -type version = [ `HTTP_1_0 | `HTTP_1_1 ] - -and meth = [ `GET ] - -and informational_substatus = [ `Continue | `Switching_protocols ] - -and success_substatus = - [ `Accepted - | `Created - | `No_content - | `Non_authoritative_information - | `OK - | `Partial_content - | `Reset_content - ] - -and redirection_substatus = - [ `Found - | `Moved_permanently - | `Multiple_choices - | `Not_modified - | `See_other - | `Temporary_redirect - | `Use_proxy - ] - -and client_error_substatus = - [ `Bad_request - | `Conflict - | `Expectation_failed - | `Forbidden - | `Gone - | `Length_required - | `Method_not_allowed - | `Not_acceptable - | `Not_found - | `Payment_required - | `Precondition_failed - | `Proxy_authentication_required - | `Request_URI_too_large - | `Request_entity_too_large - | `Request_time_out - | `Requested_range_not_satisfiable - | `Unauthorized - | `Unsupported_media_type - ] - -and server_error_substatus = - [ `Bad_gateway - | `Gateway_time_out - | `HTTP_version_not_supported - | `Internal_server_error - | `Not_implemented - | `Service_unavailable - ] - -and informational_status = [ `Informational of informational_substatus ] -and success_status = [ `Success of success_substatus ] -and redirection_status = [ `Redirection of redirection_substatus ] -and client_error_status = [ `Client_error of client_error_substatus ] -and server_error_status = [ `Server_error of server_error_substatus ] - -and error_status = - [ `Client_error of client_error_substatus - | `Server_error of server_error_substatus - ] - -and status = - [ `Client_error of client_error_substatus - | `Informational of informational_substatus - | `Redirection of redirection_substatus - | `Server_error of server_error_substatus - | `Success of success_substatus - ] - -class type response = - object - method addContents : string -> unit - method addContentsBuf : Buffer.t -> unit - method addHeader : name:string -> value:string -> unit - method code : int - method contentEncoding : string - method contentType : string - method contents : string - method contentsBuf : Buffer.t - method date : string - method expires : string - method hasHeader : name:string -> bool - method header : name:string -> string - method headers : (string * string) list - method isClientError : bool - method isError : bool - method isInformational : bool - method isRedirection : bool - method isServerError : bool - method isSuccess : bool - method reason : string - method removeHeader : name:string -> unit - method replaceHeader : name:string -> value:string -> unit - method serialize : out_channel -> unit - method server : string - method setCode : int -> unit - method setContentEncoding : string -> unit - method setContentType : string -> unit - method setContents : string -> unit - method setContentsBuf : Buffer.t -> unit - method setDate : string -> unit - method setExpires : string -> unit - method setReason : string -> unit - method setServer : string -> unit - method setStatus : status -> unit - method setStatusLine : string -> unit - method setVersion : version -> unit - method status : status - method statusLine : string - method version : version - end - -class type request = - object - method uri: string - method path: string - method param: string -> string - method params: (string * string) list - end - -- 2.39.2