]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/ocaml-http/http_request.ml
ocaml 3.09 transition
[helm.git] / helm / DEVEL / ocaml-http / http_request.ml
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)