From c39fad5bb124f8e9012bbae186c6e66c88bb2fa4 Mon Sep 17 00:00:00 2001 From: yekolia Date: Fri, 19 Oct 2012 15:42:28 +0000 Subject: [PATCH] Modification: - Adding support of multi-site cookies --- web/CXM_making_a_web_site.anubis | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index cd07d6e..d7d8eab 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -2090,7 +2090,8 @@ define (List(Web_arg) lwa, HTTP_Info info) -> Separated_Web_Args($State) make_separate_web_args_function ( String state_directory, - String -> PreviousState($State) retrieve_state + String -> PreviousState($State) retrieve_state, + String website_name ) = (List(Web_arg) lwa, HTTP_Info info) |-swaf-> if lwa is @@ -2099,7 +2100,7 @@ define (List(Web_arg) lwa, HTTP_Info info) -> Separated_Web_Args($State) // // no web arg found => no previous state and no action // - if find_cookie("state", server_get_cookies(http_headers(info))) is + if find_cookie("state_"+website_name, server_get_cookies(http_headers(info))) is { failure then swa(not_found,failure,[]), success(cookie) then swa(retrieve_state(value(cookie)),failure,[]) @@ -2277,11 +2278,12 @@ define Printable_tree define List(HTTP_header) make_state_cookie_headers ( + String website_name, String state_name ) = [ - http_header("Set-Cookie", "state="+state_name) + http_header("Set-Cookie", "state_"+website_name+"="+state_name) ] . @@ -2317,11 +2319,12 @@ define List(HTTP_header) (String action_name, List(Web_arg) args)-> One before_send_file ). - + public define Web_Site make_web_site_description ( + String website_name, List(String) common_names, // for example: ["www.our-business.com"] String site_directory, String state_directory, @@ -2367,7 +2370,7 @@ public define Web_Site // 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), + separate_web_args = make_separate_web_args_function(state_directory, retrieve_state, website_name), apply_action = make_apply_action_function(actions), // // construct the site handler @@ -2413,7 +2416,7 @@ public define Web_Site if substr(action_name, 0, 5)="ajax_" then [] else - make_state_cookie_headers(state_name) + make_state_cookie_headers(website_name, state_name) }, format(info(host_name, http_port, https_port, site_directory, secret), @@ -2453,6 +2456,43 @@ public define Web_Site ), delete_out_of_date). +// Compatibility function for older websites +public define Web_Site + make_web_site_description + ( + List(String) common_names, // for example: ["www.our-business.com"] + String site_directory, + String state_directory, + One -> One init, + (HTTP_Info, + List(Web_arg), + Bool is_https) -> $State initial_state, + ($State expired, + Maybe(String), + HTTP_Info, + List(Web_arg), + Bool is_https) -> $State ticket_expired_state, + (Maybe(String), + HTTP_Info, + List(Web_arg), + Bool is_https) -> $State ticket_lost_state, + List(Web_Action($State)) actions, + $State -> HTTP_Answer compute_page, + $State -> List(HTTP_header) additional_headers, + Int timeout, + Redirections redirections, + String charset, + List(String) journal_extensions, + List(String) journal_headers, + String secret, + List(MIME) known_mime_types, + (String action_name, + List(Web_arg) args) -> One before_send_file + //Bool using_state_cookies + ) + = + make_web_site_description("", common_names, site_directory, state_directory, init, initial_state, ticket_expired_state, ticket_lost_state, actions, compute_page, additional_headers, timeout, redirections, charset, journal_extensions, journal_headers, secret, known_mime_types, before_send_file) + . -- libgit2 0.21.4