From: Stefano Zacchiroli Date: Tue, 17 May 2005 22:14:49 +0000 (+0000) Subject: snapshot X-Git-Tag: single_binding~45 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=116fba9ef554e81ff483285638c05e8c9c592e65;p=helm.git snapshot --- diff --git a/helm/DEVEL/ocaml-http/debian/changelog b/helm/DEVEL/ocaml-http/debian/changelog index bc525268a..c3ebb8b62 100644 --- a/helm/DEVEL/ocaml-http/debian/changelog +++ b/helm/DEVEL/ocaml-http/debian/changelog @@ -1,3 +1,9 @@ +ocaml-http (0.1.1+dev) UNRELEASED; urgency=low + + * added ?default parameter to "param" method + + -- Stefano Zacchiroli Wed, 16 Mar 2005 09:24:07 +0100 + ocaml-http (0.1.0-2) unstable; urgency=low * rebuilt against ocaml 3.08.3 diff --git a/helm/DEVEL/ocaml-http/debian/control b/helm/DEVEL/ocaml-http/debian/control index c4fcf84a2..6fcb97b20 100644 --- a/helm/DEVEL/ocaml-http/debian/control +++ b/helm/DEVEL/ocaml-http/debian/control @@ -2,12 +2,12 @@ Source: ocaml-http Section: devel Priority: optional Maintainer: Stefano Zacchiroli -Build-Depends: debhelper (>> 4.0.0), ocaml-nox-3.08.3, ocaml-findlib, libpcre-ocaml-dev (>= 5.08.1-3), libocamlnet-ocaml-dev (>= 0.98.1-2) +Build-Depends: debhelper (>> 4.0.0), ocaml-nox-3.08.3, ocaml-findlib, libpcre-ocaml-dev (>= 5.08.1-3), libocamlnet-ocaml-dev (>= 1.0-1) Standards-Version: 3.6.1.1 Package: libhttp-ocaml-dev Architecture: any -Depends: ocaml-nox-3.08.3, libpcre-ocaml-dev (>= 5.08.1-3), libocamlnet-ocaml-dev (>= 0.98.1-2) +Depends: ocaml-nox-3.08.3, libpcre-ocaml-dev (>= 5.08.1-3), libocamlnet-ocaml-dev (>= 1.0-1) Description: OCaml library for writing HTTP servers OCaml HTTP is a library for the Objective Caml programming language, used to build simple HTTP servers, largely inspired to Perl's diff --git a/helm/DEVEL/ocaml-http/http_request.ml b/helm/DEVEL/ocaml-http/http_request.ml index 664256548..cd2dcd165 100644 --- a/helm/DEVEL/ocaml-http/http_request.ml +++ b/helm/DEVEL/ocaml-http/http_request.ml @@ -103,14 +103,16 @@ class request ic = method meth = meth method uri = uri_str method path = path - method param ?meth name = - (match (meth: meth option) with - | None -> - (try - Hashtbl.find params_tbl name - with Not_found -> raise (Param_not_found name)) - | Some `GET -> List.assoc name query_get_params - | Some `POST -> List.assoc name query_post_params) + method param ?(meth: meth option) ?(default: string option) name = + try + (match meth with + | None -> Hashtbl.find params_tbl name + | Some `GET -> List.assoc name query_get_params + | Some `POST -> List.assoc name query_post_params) + with Not_found -> + (match default with + | None -> raise (Param_not_found name) + | Some value -> value) method paramAll ?meth name = (match (meth: meth option) with | None -> List.rev (Hashtbl.find_all params_tbl name) diff --git a/helm/DEVEL/ocaml-http/http_types.ml b/helm/DEVEL/ocaml-http/http_types.ml index bc2efb413..5c88b212e 100644 --- a/helm/DEVEL/ocaml-http/http_types.ml +++ b/helm/DEVEL/ocaml-http/http_types.ml @@ -157,7 +157,7 @@ class type request = object method meth: meth method uri: string method path: string - method param: ?meth:meth -> string -> string + method param: ?meth:meth -> ?default:string -> string -> string method paramAll: ?meth:meth -> string -> string list method params: (string * string) list method params_GET: (string * string) list diff --git a/helm/DEVEL/ocaml-http/http_types.mli b/helm/DEVEL/ocaml-http/http_types.mli index eeedd2cf8..8d5832655 100644 --- a/helm/DEVEL/ocaml-http/http_types.mli +++ b/helm/DEVEL/ocaml-http/http_types.mli @@ -259,14 +259,16 @@ class type request = object (** lookup a given parameter @param meth if given restrict the lookup area (e.g. if meth = POST than - only parameters received via POST are searched), if not given both GET and - POST parameter are searched in an unspecified order (actually the - implementation prefers POST parameters but this is not granted, you've - been warned) + only parameters received via POST are searched), if not given both GET + and POST parameter are searched in an unspecified order (actually the + implementation prefers POST parameters but this is not granted, you've + been warned) + @param default if provided, this value will be returned in case no + parameter of that name is available instead of raising Param_not_found @param name name of the parameter to lookup @return value associated to parameter name @raise Param_not_found if parameter name was not found *) - method param: ?meth:meth -> string -> string + method param: ?meth:meth -> ?default:string -> string -> string (** like param above but return a list of values associated to given parameter (a parameter could be defined indeed more than once: passed more