(*
OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
- Copyright (C) <2002-2004> Stefano Zacchiroli <zack@cs.unibo.it>
+ Copyright (C) <2002-2005> Stefano Zacchiroli <zack@cs.unibo.it>
This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ GNU Library General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA
*)
(** Type definitions *)
(* | `Digest of ... (* TODO digest authentication *) *)
]
- (** informational HTTP status, see RFC2616 *)
+ (** @see "RFC2616" informational HTTP status *)
type informational_substatus =
[ `Continue
| `Switching_protocols
]
- (** success HTTP status, see RFC2616 *)
+ (** @see "RFC2616" success HTTP status *)
type success_substatus =
[ `OK
| `Created
| `Partial_content
]
- (** redirection HTTP status, see RFC2616 *)
+ (** @see "RFC2616" redirection HTTP status *)
type redirection_substatus =
[ `Multiple_choices
| `Moved_permanently
| `Temporary_redirect
]
- (** client error HTTP status, see RFC2616 *)
+ (** @see "RFC2616" client error HTTP status *)
type client_error_substatus =
[ `Bad_request
| `Unauthorized
| `Expectation_failed
]
- (** server error HTTP status, see RFC2616 *)
+ (** @see "RFC2616" server error HTTP status *)
type server_error_substatus =
[ `Internal_server_error
| `Not_implemented
(** 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
(** set response code *)
method setCode: int -> unit
- (** @return response status, see {! Http_types.status} *)
+ (** @return response status *)
method status: status
(** set response status *)
(** response is either a client error or a server error response *)
method isError: bool
- (** add basic headers to response, see {! Http_daemon.send_basic_headers}
+ (** add basic headers to response, see {!Http_daemon.send_basic_headers}
*)
method addBasicHeaders: unit
(** {2 Daemon specification} *)
- (** daemon specification, describe the behaviour of an HTTP daemon
- * @param address adress on which daemon will be listening, can be both a
- * numeric address (e.g. "127.0.0.1") and an hostname (e.g. "localhost")
- * @param auth authentication requirements (currently only basic authentication
- * is supported). If set to None no authentication is
- * required. If set to Some ("realm", `Basic ("foo", "bar")), only clients
- * authenticated with baisc authentication, for realm "realm", providing
- * username "foo" and password "bar" are accepted; others are rejected with a
- * 401 response code
- * @param callback function which will be called each time a correct HTTP
- * request will be received. 1st callback argument is an Http_types.request
- * object corresponding to the request received; 2nd argument is an output
- * channel corresponding to the socket connected to the client
- * @param mode requests handling mode, it can have three different values:
- * `Single -> all requests will be handled by the same process,
- * `Fork -> each request will be handled by a child process,
- * `Thread -> each request will be handled by a (new) thread
- * @param port TCP port on which the daemon will be listening
- * @param root_dir directory to which ocaml http will chdir before starting
- * handling requests; if None, no chdir will be performed (i.e. stay in the
- * current working directory)
- * @param exn_handler what to do when executing callback raises an exception.
- * If None, the exception will be re-raised: in `Fork/`Thread mode the
- * current process/thread will be terminated. in `Single mode the exception
- * is ignored and the client socket closed. If Some callback, the callback
- * will be executed before acting as per None; the callback is meant to
- * perform some clean up actions, like releasing global mutexes in `Thread
- * mode
- * @param timeout timeout in seconds after which an incoming HTTP request will
- * be terminated closing the corresponding TCP connection; None disable the
- * timeout
+ (** daemon specification, describe the behaviour of an HTTP daemon.
*
- * The default daemon specification is Http_daemon.default_spec
+ * The default daemon specification is {!Http_daemon.default_spec}
*)
type daemon_spec = {
address: string;
+ (** @param address adress on which daemon will be listening, can be both a
+ * numeric address (e.g. "127.0.0.1") and an hostname (e.g. "localhost") *)
auth: (string * auth_info) option;
+ (** authentication requirements (currently only basic authentication is
+ * supported). If set to None no authentication is required. If set to Some
+ * ("realm", `Basic ("foo", "bar")), only clients authenticated with baisc
+ * authentication, for realm "realm", providing username "foo" and password
+ * "bar" are accepted; others are rejected with a 401 response code *)
callback: request -> out_channel -> unit;
+ (** function which will be called each time a correct HTTP request will be
+ * received. 1st callback argument is an Http_types.request object
+ * corresponding to the request received; 2nd argument is an output channel
+ * corresponding to the socket connected to the client *)
mode: daemon_mode;
- port: int;
+ (** requests handling mode, it can have three different values:
+ * - `Single -> all requests will be handled by the same process,
+ * - `Fork -> each request will be handled by a child process,
+ * - `Thread -> each request will be handled by a (new) thread *)
+ port: int; (** TCP port on which the daemon will be listening *)
root_dir: string option;
+ (** directory to which ocaml http will chdir before starting handling
+ * requests; if None, no chdir will be performed (i.e. stay in the current
+ * working directory) *)
exn_handler: (exn -> out_channel -> unit) option;
+ (** what to do when executing callback raises an exception. If None, the
+ * exception will be re-raised: in `Fork/`Thread mode the current
+ * process/thread will be terminated. in `Single mode the exception is
+ * ignored and the client socket closed. If Some callback, the callback will
+ * be executed before acting as per None; the callback is meant to perform
+ * some clean up actions, like releasing global mutexes in `Thread mode *)
timeout: int option;
+ (** timeout in seconds after which an incoming HTTP request will be
+ * terminated closing the corresponding TCP connection; None disable the
+ * timeout *)
}
- (** {2 OO representation of other HTTP "entities"} *)
+ (** {2 OO representation of other HTTP entities} *)
(** an HTTP connection from a client to a server *)
class type connection =