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 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 : (string * string) list; (*The cookies to set*)
   res_path : string; (*The path for the cookies*)
   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 (*Used to modify the request before giving it to next extension (filter)*)
The result given by the extension (filter or page generation)
val register_extension : (Ocsimisc.virtual_hosts ->
(string option -> request_info -> answer Lwt.t) *
(string list -> Simplexmlparser.ExprOrPatt.texprpatt -> unit)) *
(unit -> unit) * (unit -> unit) * (exn -> string) -> unit
We register for each extension four functions: