Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .jenkins.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
opam pin add js_of_ocaml --dev-repo --no-action

for pkg in camlp4 compiler lwt ocamlbuild ppx tyxml; do
opam pin add js_of_ocaml-$pkg \
https://github.com/ocsigen/js_of_ocaml.git \
--no-action
done

opam pin add --no-action eliom .
opam install --deps-only eliom
opam install --verbose eliom
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.0
8.0.0
4 changes: 2 additions & 2 deletions opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opam-version: "2.0"
name: "eliom"
version: "7.0.0"
version: "8.0.0"
maintainer: "dev@ocsigen.org"
authors: "dev@ocsigen.org"
synopsis: "Client/server Web framework"
Expand All @@ -25,7 +25,7 @@ depends: [
"lwt_log"
"lwt_ppx"
"tyxml" {>= "4.4.0" & < "5.0.0"}
"ocsigenserver" {>= "2.18.0"}
"ocsigenserver" {>= "3.0.0"}
"ipaddr" {>= "2.1"}
"reactiveData" {>= "0.2.1"}
"dbm" | "sqlite3"
Expand Down
1 change: 0 additions & 1 deletion pkg/filelist.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ let server = {
"eliom_common";
"eliom_config";
"eliom_content";
"eliom_cookie";
"eliom_extension";
"eliom_lib";
"eliom_mkreg";
Expand Down
88 changes: 47 additions & 41 deletions src/lib/client/eliommod_cookies.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,31 @@

open Js_of_ocaml
open Eliom_lib
open Ocsigen_cookies

include Eliom_cookies_base

(* CCC The tables are indexed by the hostname, not the port appear.
there are no particular reason. If needed it is possible to add it *)
let cookie_tables = Jstable.create ()
let cookie_tables
: (float option * string * bool) Ocsigen_cookie_map.Map_inner.t
Ocsigen_cookie_map.Map_path.t Jstable.t
= Jstable.create ()

(** [in_local_storage] implements cookie substitutes for iOS WKWebView *)
let get_table ?(in_local_storage=false) = function
| None -> Cookies.empty
| None -> Ocsigen_cookie_map.Map_path.empty
| Some host ->
if in_local_storage then
let host = Js.string (host ^ "/substitutes") in
Js.Optdef.case (Dom_html.window##.localStorage) (fun () -> Cookies.empty)
Js.Optdef.case (Dom_html.window##.localStorage)
(fun () -> Ocsigen_cookie_map.Map_path.empty)
(fun st ->
Js.Opt.case (st##(getItem host))
(fun () -> Cookies.empty)
(fun () -> Ocsigen_cookie_map.Map_path.empty)
(fun v -> Json.unsafe_input v))
else
Js.Optdef.get (Jstable.find cookie_tables (Js.string host))
(fun () -> Cookies.empty)
(fun () -> Ocsigen_cookie_map.Map_path.empty)

(** [in_local_storage] implements cookie substitutes for iOS WKWebView *)
let set_table ?(in_local_storage=false) host t =
Expand All @@ -60,53 +63,56 @@ let now () =
Js.to_float (date##getTime) /. 1000.

(** [in_local_storage] implements cookie substitutes for iOS WKWebView *)
let update_cookie_table ?(in_local_storage=false) host cookieset =
let update_cookie_table ?(in_local_storage=false) host cookies =
let now = now () in
Cookies.iter
Ocsigen_cookie_map.Map_path.iter
(fun path table ->
CookiesTable.iter
(fun name -> function
| OSet (Some exp, _, _) when exp <= now ->
set_table ~in_local_storage
host (remove_cookie path name (get_table ~in_local_storage host))
| OUnset ->
set_table ~in_local_storage
host (remove_cookie path name (get_table ~in_local_storage host))
| OSet (exp, value, secure) ->
set_table ~in_local_storage
host (add_cookie path name (exp, value, secure)
(get_table ~in_local_storage host)))
table
)
cookieset
Ocsigen_cookie_map.Map_inner.iter
(fun name -> function
| OSet (Some exp, _, _) when exp <= now ->
set_table ~in_local_storage host
(Ocsigen_cookie_map.Poly.remove ~path name
(get_table ~in_local_storage host))
| OUnset ->
set_table ~in_local_storage host
(Ocsigen_cookie_map.Poly.remove ~path name
(get_table ~in_local_storage host))
| OSet (exp, value, secure) ->
set_table ~in_local_storage host
(Ocsigen_cookie_map.Poly.add ~path name
(exp, value, secure)
(get_table ~in_local_storage host)))
table)
cookies

(** [in_local_storage] implements cookie substitutes for iOS WKWebView *)
let get_cookies_to_send ?(in_local_storage=false) host https path =
let now = now () in
Cookies.fold
Ocsigen_cookie_map.Map_path.fold
(fun cpath t cookies_to_send ->
if Url.is_prefix_skip_end_slash
(Url.remove_slash_at_beginning cpath)
(Url.remove_slash_at_beginning path)
then CookiesTable.fold
(fun name (exp, value, secure) cookies_to_send ->
match exp with
| Some exp when exp <= now ->
set_table ~in_local_storage host
(remove_cookie cpath name (get_table ~in_local_storage host));
cookies_to_send
| _ ->
if (not secure) || https
then (name,value)::cookies_to_send
else cookies_to_send
)
t
cookies_to_send
else cookies_to_send
)
then
Ocsigen_cookie_map.Map_inner.fold
(fun name (exp, value, secure) cookies_to_send ->
match exp with
| Some exp when exp <= now ->
set_table ~in_local_storage host
(Ocsigen_cookie_map.Poly.remove cpath
name (get_table ~in_local_storage host));
cookies_to_send
| _ ->
if (not secure) || https
then (name,value)::cookies_to_send
else cookies_to_send)
t cookies_to_send
else
cookies_to_send)
(get_table ~in_local_storage host)
[]


let make_new_session_id () =
failwith "Cannot define anonymous coservices on client side. Ask their values to the server."
failwith "Cannot define anonymous coservices on client side. \
Ask their values to the server."
11 changes: 4 additions & 7 deletions src/lib/eliom_client.client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,10 @@ let init_client_app
Eliom_process.set_request_template None;
(* We set the tab cookie table, with the app name inside: *)
Eliom_process.set_request_cookies
(Ocsigen_cookies.Cookies.add
[]
(Ocsigen_cookies.CookiesTable.add
Eliom_common.appl_name_cookie_name
(Eliommod_cookies.OSet (None, app_name, false))
Ocsigen_cookies.CookiesTable.empty)
Ocsigen_cookies.Cookies.empty);
(Ocsigen_cookie_map.add ~path:[]
Eliom_common.appl_name_cookie_name
(Ocsigen_cookie_map.OSet (None, app_name, false))
Ocsigen_cookie_map.empty);
ignore (get_global_data ())

let is_client_app () = !Eliom_common.is_client_app
Expand Down
2 changes: 1 addition & 1 deletion src/lib/eliom_client.server.mli
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ val server_function :
?charset:string ->
?code:int ->
?content_type:string ->
?headers:Http_headers.t ->
?headers:Ocsigen_header.t ->
?secure_session:bool ->
?name:string ->
?csrf_safe:bool ->
Expand Down
6 changes: 4 additions & 2 deletions src/lib/eliom_comet.server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,10 @@ end = struct
handler.hd_registered_chan_id <- List.filter ((<>) chan_id) handler.hd_registered_chan_id

let wait_closed_connection () =
let ri = Eliom_request_info.get_ri () in
let%lwt () = Ocsigen_extensions.Ocsigen_request_info.connection_closed ri in
let%lwt () =
Ocsigen_request.connection_closed
(Eliom_request_info.get_ri ())
in
Lwt.fail Connection_closed

(* register the service handler.hd_service *)
Expand Down
Loading