Module Ocsigen_http_frame

module Ocsigen_http_frame: sig..end

This table is to store cookie values for each path. The key has type url_path option: it is for the path (default: root of the site),


type etag = string

type url_path = string list

module Cookies:
   Map.S  
    with type key = url_path

This table is to store cookie values for each path.

module Cookievalues:
   Map.S  
    with type key = string

This table is to store one cookie value for each cookie name.

type cookie =

|OSet of float option * string
|OUnset

Type used for cookies to set. The float option is the timestamp for the expiration date. The string is the value.

type cookieset =
   cookie Cookievalues.t
    Cookies.t

add_cookie c cookie_table adds the cookie c to the table cookie_table. If the cookie is already bound, the previous binding disappear.

val add_cookies :
   cookie Cookievalues.t
    Cookies.t ->
    cookie Cookievalues.t
    Cookies.t ->
    cookie Cookievalues.t
    Cookies.t

add_cookies newcookies oldcookies adds the cookies from newcookies to oldcookies. If cookies are already bound in oldcookies, the previous binding disappear.

val compute_new_ri_cookies :
   float ->
    string list ->
    string Cookievalues.t ->
    cookie Cookievalues.t
    Cookies.t -> string Cookievalues.t

compute_new_ri_cookies now path ri_cookies cookies_to_set adds the cookies from cookies_to_set to ri_cookies, as if the cookies add been send to the browser and the browser was doing a new request to the url path. Only the cookies that match path (current path) are added.

type result = {

   res_cookies : cookieset;(*cookies to set*)
   res_lastmodified : float option;(*Default: None*)
   res_etag : etag option;
   res_code : int;(*HTTP code, if not 200*)
   res_stream : string Ocsigen_stream.t;(*Default: empty stream*)
   res_stop_stream : unit -> unit Lwt.t;(*A function that will be called if sending the stream fails. It is called before the stream finalizer, only in case of error. Use it if you want a different behaviour if sending succeeds or not. Default is do nothing (Lwt.return).*)
   res_content_length : int64 option;(*None means Transfer-encoding: chunked*)
   res_content_type : string option;
   res_headers : Http_headers.t;(*The headers you want to add*)
   res_charset : string option;(*Default: None*)
   res_location : string option;(*Default: None*)

}

The type of answers to send

val default_result : unit -> result

Default result to use as a base for constructing others.

val empty_result : unit -> result

result for an empty page.

module type HTTP_CONTENT = sig..end

module Http_header: sig..end

module Http_error: sig..end

type t = {

   header : Http_header.http_header;
   content : string Ocsigen_stream.t option;
   abort : unit -> unit Lwt.t;

}

The type of HTTP frames. The content may be void (no body) or a stream. While sending, a stream will be sent with chunked encoding if no content-length is supplied. abort is the function to be called if you want to cancel the stream reading (closes the connection).