Module Extensions


module Extensions: sig .. end
type of URLs, without parameter

exception Ocsigen_404
exception Ocsigen_Is_a_directory
exception Ocsigen_malformed_url
exception Ocsigen_Internal_Error of string
exception Bad_config_tag_for_extension of string
exception Error_in_config_file of string
type url_path = string list 
type of URLs, without parameter
type current_url = string list 
type current_dir = string list 

type cookies =
| Set of string list option * float option * (string * string) list
| Unset of (string list option * string list)
Type used for cookies to set. The url_path option is for the path, The float option is the timestamp for the expiration date.
type cookieslist = cookies list 
val change_cookie : cookies ->
string list option * float option * (string * string) list

type file_info = {
   tmp_filename : string; (*Where the file is stored on the server*)
   filesize : int64; (*Size, in bytes*)
   original_filename : string; (*Original file name*)
}
The files sent in the request

Note that the files are cancelled once the request has been fulfilled


type request_info = {
   ri_url : string;
   ri_path_string : string; (*path of the URL*)
   ri_path : string list; (*path of the URL*)
   ri_params : string; (*string containing parameters*)
   ri_host : string option; (*Host field of the request (if any)*)
   ri_get_params : (string * string) list Lazy.t; (*Association list of get parameters*)
   ri_post_params : (string * string) list Lwt.t Lazy.t; (*Association list of post parameters*)
   ri_files : (string * file_info) list Lwt.t Lazy.t; (*Files sent in the request*)
   ri_inet_addr : Unix.inet_addr; (*IP of the client*)
   ri_ip : string; (*IP of the client*)
   ri_port : int; (*Port of the request*)
   ri_user_agent : string; (*User_agent of the browser*)
   ri_cookies : (string * string) list Lazy.t; (*Cookie sent by the browser*)
   ri_ifmodifiedsince : float option; (*if-modified-since field*)
   ri_http_frame : Predefined_senders.Stream_http_frame.http_frame; (*The full http_frame*)
}
The request

If you force ri_files or ri_post_params, the request is fully read, so it is not possible any more to read it from ri_http_frame (and vice versa).

type result = {
   res_cookies : cookieslist; (*The cookies to set (with optional paths)*)
   res_lastmodified : float option; (*Last modified date*)
   res_etag : Http_frame.etag option; (*ETag for the page*)
   res_code : int option; (*HTTP code to send, if not 200*)
   res_send_page : Predefined_senders.send_page_type; (*A function from Predefined_senders, for example Predefined_senders.send_xhtml_page*)
   res_create_sender : Predefined_senders.create_sender_type; (*A function from Predefined_senders, for example Predefined_senders.create_xhtml_sender*)
   res_charset : string option; (*Charset used by the page*)
}
The result of a page generation
type charset_tree_type 
Charset for each directory

type answer =
| Ext_found of result (*OK stop! I found the page*)
| Ext_not_found (*Page not found. Try next extension.*)
| Ext_continue_with of request_info * cookieslist (*Used to modify the request before giving it to next extension ; The extension may want to set cookies ; in that case, put the new cookies in the list (and possibly the path in the string list option of cookieslist), and possibly in the ri_cookies field of request_info if you want them to be seen by the following extension.*)
| Ext_retry_with of request_info * cookieslist (*Used to retry all the extensions with a new request_info ; May set cookies (idem)*)
The result given by the extension (filter or page generation)
module R: sig .. end
We register for each extension four functions: a function that will be called for each virtual server, generating two functions:, one that will be called to generate the pages (from charset (string option) and request_info), one to parse the configuration file, a function that will be called at the beginning of the initialisation phase , a function that will be called at the end of the initialisation phase of the server, a function that will create an error message from the exceptions that may be raised during the initialisation phase, and raise again all other exceptions
val get_config : unit -> Simplexmlparser.xml list
While loading an extension, get the configuration tree between <dynlink></dynlink>