Commit 8b0a26ee5218e4c0430b8bd850a3b93169030853

Authored by totoro
1 parent 4bb63871

Start to change the behavior of the action name.

Now in add of ?a= (which means action =) we defined the ?aws_action= (which means 'Anubis Web Server Action = ')
the 'a=' will be deprecated in the future because 'a' can be web argument name too easily.
In addition of the new name for action, there is an action which is special for not using session stored in cookie.
When ...?aws_action=none this means don't restore session state for this action like action name which starting "ajax_".
Showing 1 changed file with 33 additions and 63 deletions   Show diff stats
web/CXM_making_a_web_site.anubis
@@ -2238,6 +2238,7 @@ define (List(Web_arg) lwa, HTTP_Info info) -> Separated_Web_Args($State) @@ -2238,6 +2238,7 @@ define (List(Web_arg) lwa, HTTP_Info info) -> Separated_Web_Args($State)
2238 // 2238 //
2239 // no web arg found => no previous state and no action 2239 // no web arg found => no previous state and no action
2240 // 2240 //
  2241 + //println("find_cookie(\"state_"+website_name+"\", ...");
2241 if find_cookie("state_"+website_name, server_get_cookies(http_headers(info))) is 2242 if find_cookie("state_"+website_name, server_get_cookies(http_headers(info))) is
2242 { 2243 {
2243 failure then swa(not_found,failure,[]), 2244 failure then swa(not_found,failure,[]),
@@ -2263,8 +2264,10 @@ define (List(Web_arg) lwa, HTTP_Info info) -> Separated_Web_Args($State) @@ -2263,8 +2264,10 @@ define (List(Web_arg) lwa, HTTP_Info info) -> Separated_Web_Args($State)
2263 with name = if substr(n,0,4) = "amp;" then substr(n, 4, length(n) - 4) else n, 2264 with name = if substr(n,0,4) = "amp;" then substr(n, 4, length(n) - 4) else n,
2264 if name = "a" then 2265 if name = "a" then
2265 swa(ps1,success(value),op1) 2266 swa(ps1,success(value),op1)
2266 - else if name = "t" then  
2267 - swa(ps1,an1,[web_arg("target",value) . op1]) 2267 + else if name = "aws_action" then
  2268 + swa(ps1,success(value),op1)
  2269 + //else if name = "t" then
  2270 + // swa(ps1,an1,[web_arg("target",value) . op1])
2268 else 2271 else
2269 swa(ps1,an1,[web_arg(name,value) . op1]), 2272 swa(ps1,an1,[web_arg(name,value) . op1]),
2270 2273
@@ -2424,41 +2427,8 @@ define List(HTTP_header) @@ -2424,41 +2427,8 @@ define List(HTTP_header)
2424 http_header("Set-Cookie", "state_"+website_name+"="+state_name) 2427 http_header("Set-Cookie", "state_"+website_name+"="+state_name)
2425 ] 2428 ]
2426 . 2429 .
2427 -  
2428 - public define Web_Site  
2429 - make_web_site_description  
2430 - (  
2431 - List(String) common_names, // for example: ["www.our-business.com",  
2432 - // "192.168.0.1"]  
2433 - // the second one is just for testing  
2434 - String site_directory, // where 'public' and other directories are  
2435 - // located (should NOT end with '/')  
2436 - One -> One init,  
2437 - (HTTP_Info,  
2438 - List(Web_arg),  
2439 - Bool is_https) -> $State initial_state,  
2440 - ($State expired,  
2441 - HTTP_Info,  
2442 - List(Web_arg),  
2443 - Bool is_https) -> $State ticket_expired_state,  
2444 - (HTTP_Info,  
2445 - List(Web_arg),  
2446 - Bool is_https) -> $State ticket_lost_state,  
2447 - List(Web_Action($State)) actions,  
2448 - $State -> HTTP_Answer compute_page,  
2449 - $State -> List(HTTP_header) additional_headers,  
2450 - Int timeout, // seconds (todo: minutes)  
2451 - Redirections redirections,  
2452 - String charset,  
2453 - List(String) journal_extensions,  
2454 - List(String) journal_headers,  
2455 - String authorization_secret,  
2456 - List(MIME) known_mime_types,  
2457 - (String action_name,  
2458 - List(Web_arg) args)-> One before_send_file  
2459 - ).  
2460 2430
2461 - 2431 +
2462 public define Web_Site 2432 public define Web_Site
2463 make_web_site_description 2433 make_web_site_description
2464 ( 2434 (
@@ -2519,31 +2489,29 @@ public define Web_Site @@ -2519,31 +2489,29 @@ public define Web_Site
2519 List(Web_arg) lwa, 2489 List(Web_arg) lwa,
2520 Bool is_https) |-> 2490 Bool is_https) |->
2521 //(Printable_tree) 2491 //(Printable_tree)
2522 - if separate_web_args(lwa, http_info) is  
2523 - {  
2524 - swa(mb_previous_state, mb_action_name, operands) then  
2525 - with new_state = if mb_previous_state is  
2526 - {  
2527 - not_found then  
2528 - //println("previous state not found");  
2529 - if mb_action_name is  
2530 - {  
2531 - failure then initial_state(http_info, operands, is_https),  
2532 - success(_) then  
2533 - ticket_lost_state(mb_action_name, http_info,operands,is_https)  
2534 - },  
2535 -  
2536 - out_of_date(state) then  
2537 - ticket_expired_state(state, mb_action_name, http_info,operands,is_https),  
2538 -  
2539 - still_valid(state) then  
2540 - if mb_action_name is  
2541 - {  
2542 - failure then state,  
2543 - success(action_name) then  
2544 - apply_action(state,action_name,http_info,operands,is_https)  
2545 - }  
2546 - }, 2492 + since separate_web_args(lwa, http_info) is swa(mb_previous_state, mb_action_name, operands),
  2493 + with new_state = if mb_previous_state is
  2494 + {
  2495 + not_found then
  2496 + //println("previous state not found");
  2497 + if mb_action_name is
  2498 + {
  2499 + failure then initial_state(http_info, operands, is_https),
  2500 + success(_) then
  2501 + ticket_lost_state(mb_action_name, http_info,operands,is_https)
  2502 + },
  2503 +
  2504 + out_of_date(state) then
  2505 + ticket_expired_state(state, mb_action_name, http_info,operands,is_https),
  2506 +
  2507 + still_valid(state) then
  2508 + if mb_action_name is
  2509 + {
  2510 + failure then state,
  2511 + success(action_name) then
  2512 + apply_action(state,action_name,http_info,operands,is_https)
  2513 + }
  2514 + },
2547 //if state_and_headers is (session_ticket, mb_new_state, headers) then 2515 //if state_and_headers is (session_ticket, mb_new_state, headers) then
2548 with state_name = save_state(new_state), 2516 with state_name = save_state(new_state),
2549 //println("Cookie new STATE NAME "+state_name); 2517 //println("Cookie new STATE NAME "+state_name);
@@ -2551,7 +2519,9 @@ public define Web_Site @@ -2551,7 +2519,9 @@ public define Web_Site
2551 { 2519 {
2552 failure then [], 2520 failure then [],
2553 success(action_name) then 2521 success(action_name) then
2554 - if substr(action_name, 0, 5)="ajax_" then 2522 + if action_name = "none" then
  2523 + []
  2524 + else if substr(action_name, 0, 5)="ajax_" then
2555 [] 2525 []
2556 else 2526 else
2557 make_state_cookie_headers(website_name, state_name) 2527 make_state_cookie_headers(website_name, state_name)
@@ -2563,7 +2533,7 @@ public define Web_Site @@ -2563,7 +2533,7 @@ public define Web_Site
2563 compute_page(new_state), 2533 compute_page(new_state),
2564 is_https, 2534 is_https,
2565 charset) 2535 charset)
2566 - }), 2536 + ),
2567 // 2537 //
2568 // make the delete_out_of_date function 2538 // make the delete_out_of_date function
2569 // 2539 //