Commit 1b48e26b81cdc8fdf8cbd8b20ddb2b8e238b1aa6
1 parent
ec213933
Adding "Bool using_state_cookies" in "public type Web_Site_Description" in "web/…
…CXM_multihost_http_server.anubis".
Adding "Bool using_state_cookies" in "make_web_site_description" in "web/CXM_making_a_web_site.anubis"
Adding "make_state_cookie_headers" in "web/CXM_making_a_web_site.anubis"
TODO in "web/CXM_making_a_web_site.anubis" line 2295 :
// TODO 'make_separate_web_args_function' must retrieve state_cookies before parsing web_args if using_state_cookies is true
Showing
2 changed files
with
24 additions
and
7 deletions
Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
| @@ -2235,7 +2235,18 @@ define Printable_tree | @@ -2235,7 +2235,18 @@ define Printable_tree | ||
| 2235 | { | 2235 | { |
| 2236 | absolute(x) then ["\"",x,"\""], | 2236 | absolute(x) then ["\"",x,"\""], |
| 2237 | percentage(x) then ["\"",x,"%\""] | 2237 | percentage(x) then ["\"",x,"%\""] |
| 2238 | - }. | 2238 | + }. |
| 2239 | + | ||
| 2240 | +define List(HTTP_header) | ||
| 2241 | + make_state_cookie_headers | ||
| 2242 | + ( | ||
| 2243 | + String state_name | ||
| 2244 | + ) | ||
| 2245 | + = | ||
| 2246 | + [ | ||
| 2247 | + http_header("Set-Cookie", "s="+state_name) | ||
| 2248 | + ] | ||
| 2249 | + . | ||
| 2239 | 2250 | ||
| 2240 | public define Web_Site | 2251 | public define Web_Site |
| 2241 | make_web_site_description | 2252 | make_web_site_description |
| @@ -2266,7 +2277,8 @@ public define Web_Site | @@ -2266,7 +2277,8 @@ public define Web_Site | ||
| 2266 | String secret, | 2277 | String secret, |
| 2267 | List(MIME) known_mime_types, | 2278 | List(MIME) known_mime_types, |
| 2268 | (String action_name, | 2279 | (String action_name, |
| 2269 | - List(Web_arg) args) -> One before_send_file | 2280 | + List(Web_arg) args) -> One before_send_file, |
| 2281 | + Bool using_state_cookies | ||
| 2270 | ) = | 2282 | ) = |
| 2271 | init(unique); | 2283 | init(unique); |
| 2272 | 2284 | ||
| @@ -2280,7 +2292,7 @@ public define Web_Site | @@ -2280,7 +2292,7 @@ public define Web_Site | ||
| 2280 | forget((String)make_directory(site_directory+"/public")); | 2292 | forget((String)make_directory(site_directory+"/public")); |
| 2281 | // | 2293 | // |
| 2282 | // construct tool functions | 2294 | // construct tool functions |
| 2283 | - // | 2295 | + // TODO 'make_separate_web_args_function' must retrieve state_cookies before parsing web_args if using_state_cookies is true |
| 2284 | with save_state = make_save_state_function(timeout,state_directory), | 2296 | with save_state = make_save_state_function(timeout,state_directory), |
| 2285 | retrieve_state = make_retrieve_state_function(state_directory), | 2297 | retrieve_state = make_retrieve_state_function(state_directory), |
| 2286 | separate_web_args = make_separate_web_args_function(state_directory,retrieve_state), | 2298 | separate_web_args = make_separate_web_args_function(state_directory,retrieve_state), |
| @@ -2330,9 +2342,10 @@ public define Web_Site | @@ -2330,9 +2342,10 @@ public define Web_Site | ||
| 2330 | }, | 2342 | }, |
| 2331 | if state_and_headers is (session_ticket, mb_new_state, headers) then | 2343 | if state_and_headers is (session_ticket, mb_new_state, headers) then |
| 2332 | with state_name = save_state(mb_new_state), | 2344 | with state_name = save_state(mb_new_state), |
| 2345 | + with cookie_headers = if using_state_cookies then make_state_cookie_headers(state_name) else [], | ||
| 2333 | format(info(host_name, http_port, https_port, site_directory, secret), | 2346 | format(info(host_name, http_port, https_port, site_directory, secret), |
| 2334 | state_name, | 2347 | state_name, |
| 2335 | - headers, | 2348 | + headers + cookie_headers, |
| 2336 | compute_page(session_ticket, mb_new_state, state_name, operands), | 2349 | compute_page(session_ticket, mb_new_state, state_name, operands), |
| 2337 | is_https, | 2350 | is_https, |
| 2338 | charset) | 2351 | charset) |
| @@ -2362,7 +2375,9 @@ public define Web_Site | @@ -2362,7 +2375,9 @@ public define Web_Site | ||
| 2362 | { | 2375 | { |
| 2363 | failure then unique | 2376 | failure then unique |
| 2364 | success(an) then before_send_file(an,operands) | 2377 | success(an) then before_send_file(an,operands) |
| 2365 | - }), | 2378 | + }, |
| 2379 | + using_state_cookies | ||
| 2380 | + ), | ||
| 2366 | delete_out_of_date). | 2381 | delete_out_of_date). |
| 2367 | 2382 | ||
| 2368 | 2383 |
calexium_lib/web/CXM_multihost_http_server.anubis
| @@ -210,7 +210,9 @@ public type Web_Site_Description: | @@ -210,7 +210,9 @@ public type Web_Site_Description: | ||
| 210 | HTTP_Info http_info, | 210 | HTTP_Info http_info, |
| 211 | List(Web_arg) lwa, | 211 | List(Web_arg) lwa, |
| 212 | Bool is_https) -> (Printable_tree) awp_handler, | 212 | Bool is_https) -> (Printable_tree) awp_handler, |
| 213 | - (List(Web_arg) lwa) -> One before_send_file). | 213 | + (List(Web_arg) lwa) -> One before_send_file, |
| 214 | + Bool using_state_cookies, | ||
| 215 | + ). | ||
| 214 | 216 | ||
| 215 | The component 'common_names' is the list of names of the site, like for example | 217 | The component 'common_names' is the list of names of the site, like for example |
| 216 | "www.our-business.com". The reason why we have a list of common names instead of a | 218 | "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)) | @@ -3003,7 +3005,7 @@ define Maybe((String,Web_Site_Description)) | ||
| 3003 | { | 3005 | { |
| 3004 | [ ] then print("Requested host '"+requested_host+"' does not exist.\n"); failure, | 3006 | [ ] then print("Requested host '"+requested_host+"' does not exist.\n"); failure, |
| 3005 | [site1 . others] then | 3007 | [site1 . others] then |
| 3006 | - if site1 is web_site_description(common_names,_,_,_,_,_,_,_,_,_) then | 3008 | + if site1 is web_site_description(common_names,_,_,_,_,_,_,_,_,_,_) then |
| 3007 | if member(common_names,requested_host) | 3009 | if member(common_names,requested_host) |
| 3008 | then success((requested_host,site1)) | 3010 | then success((requested_host,site1)) |
| 3009 | else get_site(requested_host,others) | 3011 | else get_site(requested_host,others) |