]> matita.cs.unibo.it Git - helm.git/commitdiff
snapshot
authorStefano Zacchiroli <zack@upsilon.cc>
Tue, 17 May 2005 22:14:49 +0000 (22:14 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Tue, 17 May 2005 22:14:49 +0000 (22:14 +0000)
helm/DEVEL/ocaml-http/debian/changelog
helm/DEVEL/ocaml-http/debian/control
helm/DEVEL/ocaml-http/http_request.ml
helm/DEVEL/ocaml-http/http_types.ml
helm/DEVEL/ocaml-http/http_types.mli

index bc525268a90bd8d9faa8ed2b168d97c90cb1c5ce..c3ebb8b62cf2ebe37d82947449bca5887f11ed25 100644 (file)
@@ -1,3 +1,9 @@
+ocaml-http (0.1.1+dev) UNRELEASED; urgency=low
+
+  * added ?default parameter to "param" method
+
+ -- Stefano Zacchiroli <zack@debian.org>  Wed, 16 Mar 2005 09:24:07 +0100
+
 ocaml-http (0.1.0-2) unstable; urgency=low
 
   * rebuilt against ocaml 3.08.3
index c4fcf84a20d29c0b3e17dbaeb117ab2376e3f11b..6fcb97b20a71dbb4a7036f07d7b6a5539b52ef2b 100644 (file)
@@ -2,12 +2,12 @@ Source: ocaml-http
 Section: devel
 Priority: optional
 Maintainer: Stefano Zacchiroli <zack@debian.org>
-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
index 664256548f047aa692e408bf680768cd7c04f2e9..cd2dcd16563f8dfdd1139ba951e8720e54520dae 100644 (file)
@@ -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)
index bc2efb4131a5d6b8a0aecfe08ddccc5fed73468f..5c88b212ed010990015a936355824685f6d737d8 100644 (file)
@@ -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
index eeedd2cf8e0c1ee05012ca9a37e67183423771c6..8d58326550bfac4d54564fde11a17d9789ae5837 100644 (file)
@@ -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