diff --git a/calexium_lib/web/CXM_making_a_web_site.anubis b/calexium_lib/web/CXM_making_a_web_site.anubis index 501e6b5..1b3871a 100644 --- a/calexium_lib/web/CXM_making_a_web_site.anubis +++ b/calexium_lib/web/CXM_making_a_web_site.anubis @@ -2235,7 +2235,18 @@ define Printable_tree { absolute(x) then ["\"",x,"\""], percentage(x) then ["\"",x,"%\""] - }. + }. + +define List(HTTP_header) + make_state_cookie_headers + ( + String state_name + ) + = + [ + http_header("Set-Cookie", "s="+state_name) + ] + . public define Web_Site make_web_site_description @@ -2266,7 +2277,8 @@ public define Web_Site String secret, List(MIME) known_mime_types, (String action_name, - List(Web_arg) args) -> One before_send_file + List(Web_arg) args) -> One before_send_file, + Bool using_state_cookies ) = init(unique); @@ -2280,7 +2292,7 @@ public define Web_Site forget((String)make_directory(site_directory+"/public")); // // construct tool functions - // + // TODO 'make_separate_web_args_function' must retrieve state_cookies before parsing web_args if using_state_cookies is true with save_state = make_save_state_function(timeout,state_directory), retrieve_state = make_retrieve_state_function(state_directory), separate_web_args = make_separate_web_args_function(state_directory,retrieve_state), @@ -2330,9 +2342,10 @@ public define Web_Site }, if state_and_headers is (session_ticket, mb_new_state, headers) then with state_name = save_state(mb_new_state), + with cookie_headers = if using_state_cookies then make_state_cookie_headers(state_name) else [], format(info(host_name, http_port, https_port, site_directory, secret), state_name, - headers, + headers + cookie_headers, compute_page(session_ticket, mb_new_state, state_name, operands), is_https, charset) @@ -2362,7 +2375,9 @@ public define Web_Site { failure then unique success(an) then before_send_file(an,operands) - }), + }, + using_state_cookies + ), delete_out_of_date). diff --git a/calexium_lib/web/CXM_multihost_http_server.anubis b/calexium_lib/web/CXM_multihost_http_server.anubis index 4665c2f..2b13d4a 100644 --- a/calexium_lib/web/CXM_multihost_http_server.anubis +++ b/calexium_lib/web/CXM_multihost_http_server.anubis @@ -210,7 +210,9 @@ public type Web_Site_Description: HTTP_Info http_info, List(Web_arg) lwa, Bool is_https) -> (Printable_tree) awp_handler, - (List(Web_arg) lwa) -> One before_send_file). + (List(Web_arg) lwa) -> One before_send_file, + Bool using_state_cookies, + ). The component 'common_names' is the list of names of the site, like for example "www.our-business.com". The reason why we have a list of common names instead of a @@ -3003,7 +3005,7 @@ define Maybe((String,Web_Site_Description)) { [ ] then print("Requested host '"+requested_host+"' does not exist.\n"); failure, [site1 . others] then - if site1 is web_site_description(common_names,_,_,_,_,_,_,_,_,_) then + if site1 is web_site_description(common_names,_,_,_,_,_,_,_,_,_,_) then if member(common_names,requested_host) then success((requested_host,site1)) else get_site(requested_host,others) -- libgit2 0.21.4