]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/ocaml-http/http_types.ml
added support for HTTP (Basic) authentication
[helm.git] / helm / DEVEL / ocaml-http / http_types.ml
index 8840b22e9b3126b8fa5455cd5392b8eec14f2449..bbdd46a133bbcb0ba696eabd4d468b4b5a88d0d7 100644 (file)
@@ -54,6 +54,12 @@ type tcp_server =
   (in_channel -> out_channel -> unit) ->
     unit
 
+  (** authentication information *)
+type auth_info =
+  [ `Basic of string * string (* username, password *)
+(*   | `Digest of ...  (* TODO digest authentication *) *)
+  ]
+
   (** informational HTTP status, see RFC2616 *)
 type informational_substatus =
   [ `Continue
@@ -187,10 +193,16 @@ exception Invalid_status_line of string
   (** an header you were looking for was not found *)
 exception Header_not_found of string
 
-  (** raisable by callback functions to make main daemon quit, this is the only
+  (** raisable by callbacks to make main daemon quit, this is the only
   'clean' way to make start functions return *)
 exception Quit
 
+  (** raisable by callbacks to force a 401 (unauthorized) HTTP answer.
+  * This exception should be raised _before_ sending any data over given out
+  * channel.
+  * @param realm authentication realm (usually needed to prompt user) *)
+exception Unauthorized of string
+
   (** {2 OO representation of HTTP messages} *)
 
   (** HTTP generic messages. See {! Http_message.message} *)
@@ -269,6 +281,9 @@ class type request = object
       (** @return the list of all parameter received via POST *)
     method params_POST: (string * string) list
 
+      (** @return authorization information, if given by the client *)
+    method authorization: auth_info option
+
   end
 
   (** HTTP responses *)