]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/ocaml-http/http_daemon.mli
This commit was manufactured by cvs2svn to create tag 'V_0_0_5'.
[helm.git] / helm / DEVEL / ocaml-http / http_daemon.mli
index 60384b26c48a28cd7e4b41d7514de3b6750a0e27..46e8f61d58234412126b5baacfd68909bdd864c1 100644 (file)
@@ -48,6 +48,16 @@ val send_headers: headers:(string * string) list -> out_channel -> unit
   (if 'file' is given) or as a file name (if 'name' is given) *)
 val send_file: ?name:string -> ?file:in_channel -> out_channel -> unit
 
+  (** high level response function, respond on outchan sending: basic headers,
+  headers probided via 'headers' argument, body given via 'body' argument.
+  Default response status is 200, default response HTTP version is
+  Http_common.http_version *)
+val respond:
+  ?body:string -> ?headers:(string * string) list ->
+  ?version:Http_types.version -> ?code:int -> ?status:Http_types.status ->
+  out_channel ->
+    unit
+
   (** send a 404 (not found) HTTP response *)
 val respond_not_found:
   url:string -> ?version: Http_types.version -> out_channel -> unit
@@ -59,7 +69,7 @@ val respond_forbidden:
   (** send a "redirection" class response, optional body argument contains data
   that will be displayed in the body of the response, default response status is
   302 (moved permanently), only redirection status are accepted by this
-  function, other values will @raise Failure *)
+  function, other values will raise Failure *)
 val respond_redirect:
   location:string -> ?body:string ->
   ?version: Http_types.version ->
@@ -70,7 +80,7 @@ val respond_redirect:
   (** send an "error" response (i.e. 400 <= status < 600), optional body
   argument as per send_redirect, default response status is 400 (bad request),
   only error status are accepted by this function, other values will
-  @raise Failure *)
+  raise Failure *)
 val respond_error:
   ?body:string ->
   ?version: Http_types.version ->
@@ -91,12 +101,18 @@ val respond_with: Http_types.response -> out_channel -> unit
   receive as a first parameter the path required by the the HTTP client as a
   string, and a list of pair <parameter, value> representing parameters passed
   via GET. The last argument of the callback is an output_channel connected to
-  the HTTP client to which the user can write directly.  'timeout' parameter
-  sets a timeout for each request processed by the daemon, if it's set to None,
+  the HTTP client to which the user can write directly. 'timeout' parameter sets
+  a timeout for each request processed by the daemon, if it's set to None,
   daemon waits forever for completed requests (use with care!), default is 5
-  minute *)
+  minute. 'mode' parameter has 3 possible values: `Single means that all request
+  are handled by the same process, `Fork means that each request is handled by a
+  separate process, `Thread means that each request is handled by a separate
+  thread, default is `Fork; 'root' (mnemonic "document root") is the directory
+  where the daemon chdir before starting up, default is current working
+  directory *)
 val start:
-  ?addr: string -> ?port: int -> ?timeout: int option ->
+  ?addr: string -> ?port: int ->
+  ?timeout: int option -> ?mode: Http_types.daemon_mode -> ?root: string ->
   (string -> (string * string) list -> out_channel -> unit) ->
     unit
 
@@ -104,10 +120,20 @@ val start:
   one is an out_channel as per 'start', but the secondo one is a Request.request
   object *)
 val start':
-  ?addr: string -> ?port: int -> ?timeout: int option ->
+  ?addr: string -> ?port: int ->
+  ?timeout: int option -> ?mode: Http_types.daemon_mode -> ?root: string -> 
   (Http_types.request -> out_channel -> unit) ->
     unit
 
+(*
+  (** OO interface to HTTP daemons *)
+class daemon:
+  ?addr: string -> ?port: int ->
+  ?timeout: int option -> ?mode: Http_types.daemon_mode ->?root:; string -> 
+  (Http_types.request -> out_channel -> unit) ->
+    Http_types.daemon
+*)
+
   (** Trivial static pages HTTP daemon *)
 module Trivial :
   sig