Commit b051b4cb22f2ae0318f41e3cf85e0089209e3456
1 parent
713eb632
add cxm_form(form_id, options, fields)
add id in web_session, not yet used
Showing
6 changed files
with
161 additions
and
118 deletions
Show diff stats
web/CXM_form.anubis
| @@ -966,7 +966,15 @@ public define HTML_Off_Form | @@ -966,7 +966,15 @@ public define HTML_Off_Form | ||
| 966 | List(CXM_Form_Field) fields, | 966 | List(CXM_Form_Field) fields, |
| 967 | ) = | 967 | ) = |
| 968 | cxm_form(form_id, [], lwa, fields, "form_field aligned", true). | 968 | cxm_form(form_id, [], lwa, fields, "form_field aligned", true). |
| 969 | - | 969 | + |
| 970 | +public define HTML_Off_Form | ||
| 971 | + cxm_form | ||
| 972 | + ( | ||
| 973 | + String form_id, | ||
| 974 | + List(CoreAttrs) options, | ||
| 975 | + List(CXM_Form_Field) fields, | ||
| 976 | + ) = | ||
| 977 | + cxm_form(form_id, options, [], fields, "form_field aligned", true). | ||
| 970 | 978 | ||
| 971 | public define HTML_Off_Form | 979 | public define HTML_Off_Form |
| 972 | cxm_form | 980 | cxm_form |
web/CXM_making_a_web_site.anubis
| @@ -2956,9 +2956,9 @@ define (List(String) file_names) -> One | @@ -2956,9 +2956,9 @@ define (List(String) file_names) -> One | ||
| 2956 | (List(String) file_names) |-df-> | 2956 | (List(String) file_names) |-df-> |
| 2957 | if file_names is | 2957 | if file_names is |
| 2958 | { | 2958 | { |
| 2959 | - [ ] then unique, | ||
| 2960 | - [h . t] then | ||
| 2961 | - with file_path = state_directory+"/s"+h, | 2959 | + [ ] then unique, |
| 2960 | + [h . t] then | ||
| 2961 | + with file_path = state_directory+"/"+h, | ||
| 2962 | if (RetrieveResult((Int,$State)))retrieve(file_path) is ok(d) | 2962 | if (RetrieveResult((Int,$State)))retrieve(file_path) is ok(d) |
| 2963 | then ( | 2963 | then ( |
| 2964 | if d is (time_stamp,data) then | 2964 | if d is (time_stamp,data) then |
| @@ -3001,7 +3001,7 @@ define One | @@ -3001,7 +3001,7 @@ define One | ||
| 3001 | { | 3001 | { |
| 3002 | [ ] then unique, | 3002 | [ ] then unique, |
| 3003 | [h . t] then if h is (state_directory,function) then | 3003 | [h . t] then if h is (state_directory,function) then |
| 3004 | - function(directory_list(state_directory,"s*")); | 3004 | + function(directory_list(state_directory,"*")); |
| 3005 | delete_out_of_date_states(t) | 3005 | delete_out_of_date_states(t) |
| 3006 | }. | 3006 | }. |
| 3007 | 3007 | ||
| @@ -3763,16 +3763,16 @@ define (Maybe(WEB_Session), HTTP_Answer) | @@ -3763,16 +3763,16 @@ define (Maybe(WEB_Session), HTTP_Answer) | ||
| 3763 | { | 3763 | { |
| 3764 | failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), | 3764 | failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), |
| 3765 | success(new_controller) then | 3765 | success(new_controller) then |
| 3766 | - since _session is web_session(lang, entries, _, previous), | ||
| 3767 | - apply_controller_action(new_controller, controllers, _current_page_renderer, page_renderers, cinfo, web_session(lang, entries, previous, previous), failure, initial_session), | 3766 | + since _session is web_session(id, lang, entries, _, previous), |
| 3767 | + apply_controller_action(new_controller, controllers, _current_page_renderer, page_renderers, cinfo, web_session(id, lang, entries, previous, previous), failure, initial_session), | ||
| 3768 | }, | 3768 | }, |
| 3769 | redirect_to_previous(entries) then | 3769 | redirect_to_previous(entries) then |
| 3770 | if get_controller(get_String(*_session.previous_web_request.lwa, "aws_controller", "root"), controllers) is | 3770 | if get_controller(get_String(*_session.previous_web_request.lwa, "aws_controller", "root"), controllers) is |
| 3771 | { | 3771 | { |
| 3772 | failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), | 3772 | failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), |
| 3773 | success(new_controller) then | 3773 | success(new_controller) then |
| 3774 | - since _session is web_session(lang, _, _, previous), | ||
| 3775 | - apply_controller_action(new_controller, controllers, _current_page_renderer, page_renderers, cinfo, web_session(lang, entries, previous, previous), failure, initial_session), | 3774 | + since _session is web_session(id, lang, _, _, previous), |
| 3775 | + apply_controller_action(new_controller, controllers, _current_page_renderer, page_renderers, cinfo, web_session(id, lang, entries, previous, previous), failure, initial_session), | ||
| 3776 | }, | 3776 | }, |
| 3777 | //ajax(answer) then (failure, answer), | 3777 | //ajax(answer) then (failure, answer), |
| 3778 | //ajax with modified session that must be saved | 3778 | //ajax with modified session that must be saved |
| @@ -3866,11 +3866,13 @@ public define Web_Site | @@ -3866,11 +3866,13 @@ public define Web_Site | ||
| 3866 | 3866 | ||
| 3867 | out_of_date(previous_session) then | 3867 | out_of_date(previous_session) then |
| 3868 | println("previous out_of_date"); | 3868 | println("previous out_of_date"); |
| 3869 | - expired_session(previous_session, http_info, var(_lwa), is_https), | ||
| 3870 | - | 3869 | + //expired_session(previous_session, http_info, var(_lwa), is_https), |
| 3870 | + since previous_session is web_session(id, lang, entries, previous, _), | ||
| 3871 | + web_session(id, lang, entries, web_request(http_info, var(_lwa), is_https), previous) | ||
| 3872 | + | ||
| 3871 | still_valid(previous_session) then | 3873 | still_valid(previous_session) then |
| 3872 | - since previous_session is web_session(lang, entries, previous, _), | ||
| 3873 | - web_session(lang, entries, web_request(http_info, var(_lwa), is_https), previous) | 3874 | + since previous_session is web_session(id, lang, entries, previous, _), |
| 3875 | + web_session(id, lang, entries, web_request(http_info, var(_lwa), is_https), previous) | ||
| 3874 | }, | 3876 | }, |
| 3875 | 3877 | ||
| 3876 | 3878 |
web/CXM_multihost_http_server.anubis
| @@ -703,29 +703,38 @@ type Error: | @@ -703,29 +703,38 @@ type Error: | ||
| 703 | colon_expected, | 703 | colon_expected, |
| 704 | timeout(Int). | 704 | timeout(Int). |
| 705 | 705 | ||
| 706 | -type HTTP_RequestType: | ||
| 707 | - get, | ||
| 708 | - post. | 706 | +type HTTP_Request_Method: |
| 707 | + options, | ||
| 708 | + get, | ||
| 709 | + head, | ||
| 710 | + post, | ||
| 711 | + put, | ||
| 712 | + delete, | ||
| 713 | + trace, | ||
| 714 | + connect, | ||
| 715 | + extension(String) | ||
| 716 | + . | ||
| 709 | 717 | ||
| 710 | -type HTTP_RequestLine: | ||
| 711 | - request_line (HTTP_RequestType type, | ||
| 712 | - String uri, | ||
| 713 | - List(Web_arg) query_string). | 718 | +type HTTP_Request_Line: |
| 719 | + request_line( | ||
| 720 | + HTTP_Request_Method method, | ||
| 721 | + String uri, | ||
| 722 | + List(Web_arg) query_string). | ||
| 714 | 723 | ||
| 715 | type EncodingType: | 724 | type EncodingType: |
| 716 | www_url, | 725 | www_url, |
| 717 | multipart_form_data. | 726 | multipart_form_data. |
| 718 | 727 | ||
| 719 | 728 | ||
| 720 | -public type HTTP_BufferedConnection: | ||
| 721 | - http_buffered_connection(Connection conn, | ||
| 722 | - Var(ByteArray) buffer, | ||
| 723 | - Var(Int) read_pos, | ||
| 724 | - Var(List(Word8)) unput_chars // for reading requests | ||
| 725 | - ). | ||
| 726 | - | 729 | +public type HTTP_Buffered_Connection: |
| 730 | + http_buffered_connection( | ||
| 731 | + Connection conn, | ||
| 732 | + Var(ByteArray) buffer, | ||
| 733 | + Var(Int) read_pos, | ||
| 734 | + Var(List(Word8)) unput_chars // for reading requests | ||
| 735 | + ). | ||
| 727 | 736 | ||
| 728 | -public define HTTP_BufferedConnection | 737 | +public define HTTP_Buffered_Connection |
| 729 | http_buffered_connection | 738 | http_buffered_connection |
| 730 | ( | 739 | ( |
| 731 | Connection conn | 740 | Connection conn |
| @@ -741,27 +750,28 @@ public define HTTP_BufferedConnection | @@ -741,27 +750,28 @@ public define HTTP_BufferedConnection | ||
| 741 | The next function formats an error message. | 750 | The next function formats an error message. |
| 742 | 751 | ||
| 743 | public define String | 752 | public define String |
| 744 | - format | ||
| 745 | - ( | ||
| 746 | - Error msg | ||
| 747 | - ) = | ||
| 748 | - if msg is | ||
| 749 | - { | ||
| 750 | - cannot_read_from_connection then | ||
| 751 | - "Cannot read from connection.\n", | ||
| 752 | - not_get_or_post_request(s) then | ||
| 753 | - "The request did not begin by 'GET' or 'POST': "+s+".\n", | ||
| 754 | - end_of_line_expected then | ||
| 755 | - "End of line expected.\n", | ||
| 756 | - incorrect_content_length_value then | ||
| 757 | - "Incorrect value for HTTP header 'Content-Length'.\n", | ||
| 758 | - colon_expected then | ||
| 759 | - "':' was expected.\n", | ||
| 760 | - timeout(n) then | ||
| 761 | - //"time out: "+n+"\n" | ||
| 762 | - //"time out.\n" | ||
| 763 | - "" | ||
| 764 | - }. | 753 | + format |
| 754 | + ( | ||
| 755 | + Error msg | ||
| 756 | + )= | ||
| 757 | + if msg is | ||
| 758 | + { | ||
| 759 | + cannot_read_from_connection then | ||
| 760 | + "Cannot read from connection.\n", | ||
| 761 | + not_get_or_post_request(s) then | ||
| 762 | + "The request did not begin by 'GET' or 'POST': "+s+".\n", | ||
| 763 | + end_of_line_expected then | ||
| 764 | + "End of line expected.\n", | ||
| 765 | + incorrect_content_length_value then | ||
| 766 | + "Incorrect value for HTTP header 'Content-Length'.\n", | ||
| 767 | + colon_expected then | ||
| 768 | + "':' was expected.\n", | ||
| 769 | + timeout(n) then | ||
| 770 | + //"time out: "+n+"\n" | ||
| 771 | + //"time out.\n" | ||
| 772 | + "" | ||
| 773 | + } | ||
| 774 | +. | ||
| 765 | 775 | ||
| 766 | 776 | ||
| 767 | 777 | ||
| @@ -806,12 +816,12 @@ public type SState: | @@ -806,12 +816,12 @@ public type SState: | ||
| 806 | 816 | ||
| 807 | 817 | ||
| 808 | define One | 818 | define One |
| 809 | - unput // unputting a character (add it in front of the list) | ||
| 810 | - ( | ||
| 811 | - Word8 character, | ||
| 812 | - HTTP_BufferedConnection s | ||
| 813 | - ) = | ||
| 814 | - s.unput_chars <- (List(Word8))[character . *(s.unput_chars)]. | 819 | + unput // unputting a character (add it in front of the list) |
| 820 | + ( | ||
| 821 | + Word8 character, | ||
| 822 | + HTTP_Buffered_Connection s | ||
| 823 | + ) = | ||
| 824 | + s.unput_chars <- (List(Word8))[character . *(s.unput_chars)]. | ||
| 815 | 825 | ||
| 816 | 826 | ||
| 817 | 827 | ||
| @@ -861,7 +871,7 @@ define One | @@ -861,7 +871,7 @@ define One | ||
| 861 | define ReadResult | 871 | define ReadResult |
| 862 | read_from_connexion | 872 | read_from_connexion |
| 863 | ( | 873 | ( |
| 864 | - HTTP_BufferedConnection connection, | 874 | + HTTP_Buffered_Connection connection, |
| 865 | Int size, | 875 | Int size, |
| 866 | Int time_out, | 876 | Int time_out, |
| 867 | ByteArray result_buffer, | 877 | ByteArray result_buffer, |
| @@ -913,7 +923,7 @@ define Result(Error,Word8) | @@ -913,7 +923,7 @@ define Result(Error,Word8) | ||
| 913 | next_char // reading a character (check the list first, and read on the connection | 923 | next_char // reading a character (check the list first, and read on the connection |
| 914 | // only when the list is empty). | 924 | // only when the list is empty). |
| 915 | ( | 925 | ( |
| 916 | - HTTP_BufferedConnection connection | 926 | + HTTP_Buffered_Connection connection |
| 917 | // Int dead_line, | 927 | // Int dead_line, |
| 918 | // DenialOfService dos | 928 | // DenialOfService dos |
| 919 | ) = | 929 | ) = |
| @@ -969,7 +979,7 @@ define Result(Error,Word8) | @@ -969,7 +979,7 @@ define Result(Error,Word8) | ||
| 969 | define ByteArray | 979 | define ByteArray |
| 970 | get_and_erase_buffer | 980 | get_and_erase_buffer |
| 971 | ( | 981 | ( |
| 972 | - HTTP_BufferedConnection connection | 982 | + HTTP_Buffered_Connection connection |
| 973 | )= | 983 | )= |
| 974 | with head = to_byte_array(implode(*connection.unput_chars)), | 984 | with head = to_byte_array(implode(*connection.unput_chars)), |
| 975 | tail = extract(*connection.buffer, *connection.read_pos, length(*connection.buffer)), | 985 | tail = extract(*connection.buffer, *connection.read_pos, length(*connection.buffer)), |
| @@ -1003,7 +1013,7 @@ define ByteArray | @@ -1003,7 +1013,7 @@ define ByteArray | ||
| 1003 | define Result(Error,One) | 1013 | define Result(Error,One) |
| 1004 | read_and_ignore | 1014 | read_and_ignore |
| 1005 | ( | 1015 | ( |
| 1006 | - HTTP_BufferedConnection connection, // to client | 1016 | + HTTP_Buffered_Connection connection, // to client |
| 1007 | Int number_of_characters // number of characters to read and ignore | 1017 | Int number_of_characters // number of characters to read and ignore |
| 1008 | ) = | 1018 | ) = |
| 1009 | if number_of_characters =< 0 then | 1019 | if number_of_characters =< 0 then |
| @@ -1031,7 +1041,7 @@ define Result(Error,One) | @@ -1031,7 +1041,7 @@ define Result(Error,One) | ||
| 1031 | define Result(Error,String) | 1041 | define Result(Error,String) |
| 1032 | read_string | 1042 | read_string |
| 1033 | ( | 1043 | ( |
| 1034 | - HTTP_BufferedConnection connection, // connection with the client | 1044 | + HTTP_Buffered_Connection connection, // connection with the client |
| 1035 | List(Word8) so_far // characters read so far (in reverse order) | 1045 | List(Word8) so_far // characters read so far (in reverse order) |
| 1036 | ) = | 1046 | ) = |
| 1037 | if next_char(connection) is | 1047 | if next_char(connection) is |
| @@ -1237,7 +1247,7 @@ define String | @@ -1237,7 +1247,7 @@ define String | ||
| 1237 | ( | 1247 | ( |
| 1238 | Web_Site_Description desc, | 1248 | Web_Site_Description desc, |
| 1239 | Connection client_connection, | 1249 | Connection client_connection, |
| 1240 | - HTTP_RequestLine request_line, | 1250 | + HTTP_Request_Line request_line, |
| 1241 | List(HTTP_header) headers, | 1251 | List(HTTP_header) headers, |
| 1242 | List(Web_arg) web_args | 1252 | List(Web_arg) web_args |
| 1243 | ) = | 1253 | ) = |
| @@ -1325,7 +1335,7 @@ define Bool | @@ -1325,7 +1335,7 @@ define Bool | ||
| 1325 | define Result(Error,One) | 1335 | define Result(Error,One) |
| 1326 | skip_http_blanks | 1336 | skip_http_blanks |
| 1327 | ( | 1337 | ( |
| 1328 | - HTTP_BufferedConnection connection | 1338 | + HTTP_Buffered_Connection connection |
| 1329 | ) | 1339 | ) |
| 1330 | = | 1340 | = |
| 1331 | if next_char(connection) is | 1341 | if next_char(connection) is |
| @@ -1381,7 +1391,7 @@ define Result(Error,One) | @@ -1381,7 +1391,7 @@ define Result(Error,One) | ||
| 1381 | public define Result(Error,One) | 1391 | public define Result(Error,One) |
| 1382 | read_new_line | 1392 | read_new_line |
| 1383 | ( | 1393 | ( |
| 1384 | - HTTP_BufferedConnection connection | 1394 | + HTTP_Buffered_Connection connection |
| 1385 | ) = | 1395 | ) = |
| 1386 | if skip_http_blanks(connection) is | 1396 | if skip_http_blanks(connection) is |
| 1387 | { | 1397 | { |
| @@ -1412,7 +1422,7 @@ public define Result(Error,One) | @@ -1412,7 +1422,7 @@ public define Result(Error,One) | ||
| 1412 | public define Result(Error,One) | 1422 | public define Result(Error,One) |
| 1413 | skip_line | 1423 | skip_line |
| 1414 | ( | 1424 | ( |
| 1415 | - HTTP_BufferedConnection connection | 1425 | + HTTP_Buffered_Connection connection |
| 1416 | ) = | 1426 | ) = |
| 1417 | if next_char(connection) is | 1427 | if next_char(connection) is |
| 1418 | { | 1428 | { |
| @@ -1451,7 +1461,7 @@ public define Result(Error,One) | @@ -1451,7 +1461,7 @@ public define Result(Error,One) | ||
| 1451 | define Result(Error,String) | 1461 | define Result(Error,String) |
| 1452 | read_word_aux | 1462 | read_word_aux |
| 1453 | ( | 1463 | ( |
| 1454 | - HTTP_BufferedConnection connection, | 1464 | + HTTP_Buffered_Connection connection, |
| 1455 | List(Word8) so_far | 1465 | List(Word8) so_far |
| 1456 | ) = | 1466 | ) = |
| 1457 | if next_char(connection) is | 1467 | if next_char(connection) is |
| @@ -1467,7 +1477,7 @@ define Result(Error,String) | @@ -1467,7 +1477,7 @@ define Result(Error,String) | ||
| 1467 | define Result(Error,String) | 1477 | define Result(Error,String) |
| 1468 | read_word | 1478 | read_word |
| 1469 | ( | 1479 | ( |
| 1470 | - HTTP_BufferedConnection connection | 1480 | + HTTP_Buffered_Connection connection |
| 1471 | ) = | 1481 | ) = |
| 1472 | if skip_http_blanks(connection) is | 1482 | if skip_http_blanks(connection) is |
| 1473 | { | 1483 | { |
| @@ -1639,42 +1649,50 @@ public define List(Web_arg) | @@ -1639,42 +1649,50 @@ public define List(Web_arg) | ||
| 1639 | returns a datum of type 'HTTP_RequestLine' if no error arose. | 1649 | returns a datum of type 'HTTP_RequestLine' if no error arose. |
| 1640 | 1650 | ||
| 1641 | 1651 | ||
| 1642 | -define Result(Error,HTTP_RequestType) | ||
| 1643 | - identify_get_or_post | ||
| 1644 | - ( | ||
| 1645 | - String s | ||
| 1646 | - ) = | ||
| 1647 | - with ls = to_lower(s), | 1652 | +define Result(Error, HTTP_Request_Method) |
| 1653 | + identify_get_or_post | ||
| 1654 | + ( | ||
| 1655 | + String s | ||
| 1656 | + )= | ||
| 1657 | + with ls = to_lower(s), | ||
| 1648 | if ls = "get" then ok(get) else | 1658 | if ls = "get" then ok(get) else |
| 1649 | if ls = "post" then ok(post) else | 1659 | if ls = "post" then ok(post) else |
| 1650 | error(not_get_or_post_request(ls)). | 1660 | error(not_get_or_post_request(ls)). |
| 1651 | 1661 | ||
| 1652 | -public define Result(Error, HTTP_RequestLine) | 1662 | +public define Result(Error, HTTP_Request_Line) |
| 1653 | read_request_line | 1663 | read_request_line |
| 1654 | ( | 1664 | ( |
| 1655 | - HTTP_BufferedConnection connection | 1665 | + HTTP_Buffered_Connection connection |
| 1656 | ) = | 1666 | ) = |
| 1667 | + //Read the Method | ||
| 1657 | if read_word(connection) is | 1668 | if read_word(connection) is |
| 1658 | { | 1669 | { |
| 1659 | - error(msg) then error(msg), | ||
| 1660 | - ok(get_or_post) then | 1670 | + error(msg) then error(msg), |
| 1671 | + ok(method) then | ||
| 1672 | + //read the URI | ||
| 1661 | if read_word(connection) is | 1673 | if read_word(connection) is |
| 1662 | { | 1674 | { |
| 1663 | - error(msg) then error(msg), | ||
| 1664 | - ok(uri_and_query_string) then if read_word(connection) is | ||
| 1665 | - { | ||
| 1666 | - error(msg) then error(msg), | ||
| 1667 | - ok(http_version) then if read_new_line(connection) is | ||
| 1668 | - { | ||
| 1669 | - error(msg) then error(msg), | ||
| 1670 | - ok(_) then if separate_uri_from_query_string(uri_and_query_string,0) is | ||
| 1671 | - (uri,query_string) then if identify_get_or_post(get_or_post) is | ||
| 1672 | - { | ||
| 1673 | - error(msg) then error(msg), | ||
| 1674 | - ok(request_type) then | ||
| 1675 | - ok(request_line(request_type, web_to_ascii(uri, 0, []), read_www_url_encoded_web_args(query_string,0))) | ||
| 1676 | - } | ||
| 1677 | - } | 1675 | + error(msg) then error(msg), |
| 1676 | + ok(uri_and_query_string) then | ||
| 1677 | + //Read the HTTP version | ||
| 1678 | + if read_word(connection) is | ||
| 1679 | + { | ||
| 1680 | + error(msg) then error(msg), | ||
| 1681 | + ok(http_version) then | ||
| 1682 | + //read the ending CR/LF | ||
| 1683 | + if read_new_line(connection) is | ||
| 1684 | + { | ||
| 1685 | + error(msg) then error(msg), | ||
| 1686 | + ok(_) then | ||
| 1687 | + | ||
| 1688 | + if separate_uri_from_query_string(uri_and_query_string,0) is | ||
| 1689 | + (uri,query_string) then | ||
| 1690 | + if identify_get_or_post(method) is | ||
| 1691 | + { | ||
| 1692 | + error(msg) then error(msg), | ||
| 1693 | + ok(request_type) then ok(request_line(request_type, web_to_ascii(uri, 0, []), read_www_url_encoded_web_args(query_string,0))) | ||
| 1694 | + } | ||
| 1695 | + } | ||
| 1678 | } | 1696 | } |
| 1679 | } | 1697 | } |
| 1680 | }. | 1698 | }. |
| @@ -1703,7 +1721,7 @@ define Bool | @@ -1703,7 +1721,7 @@ define Bool | ||
| 1703 | define Result(Error,String) | 1721 | define Result(Error,String) |
| 1704 | read_header_name | 1722 | read_header_name |
| 1705 | ( | 1723 | ( |
| 1706 | - HTTP_BufferedConnection connection, | 1724 | + HTTP_Buffered_Connection connection, |
| 1707 | List(Word8) so_far | 1725 | List(Word8) so_far |
| 1708 | ) = | 1726 | ) = |
| 1709 | if next_char(connection) is | 1727 | if next_char(connection) is |
| @@ -1718,7 +1736,7 @@ define Result(Error,String) | @@ -1718,7 +1736,7 @@ define Result(Error,String) | ||
| 1718 | define Result(Error,One) | 1736 | define Result(Error,One) |
| 1719 | skip_colon | 1737 | skip_colon |
| 1720 | ( | 1738 | ( |
| 1721 | - HTTP_BufferedConnection connection | 1739 | + HTTP_Buffered_Connection connection |
| 1722 | ) = | 1740 | ) = |
| 1723 | //Skip the blank char until ':' | 1741 | //Skip the blank char until ':' |
| 1724 | if skip_http_blanks(connection) is | 1742 | if skip_http_blanks(connection) is |
| @@ -1738,7 +1756,7 @@ define Result(Error,One) | @@ -1738,7 +1756,7 @@ define Result(Error,One) | ||
| 1738 | define Result(Error,String) | 1756 | define Result(Error,String) |
| 1739 | read_header_value | 1757 | read_header_value |
| 1740 | ( | 1758 | ( |
| 1741 | - HTTP_BufferedConnection connection, | 1759 | + HTTP_Buffered_Connection connection, |
| 1742 | List(Word8) so_far | 1760 | List(Word8) so_far |
| 1743 | ) = | 1761 | ) = |
| 1744 | if next_char(connection) is | 1762 | if next_char(connection) is |
| @@ -1770,7 +1788,7 @@ define Result(Error,String) | @@ -1770,7 +1788,7 @@ define Result(Error,String) | ||
| 1770 | define Result(Error,Maybe(HTTP_header)) | 1788 | define Result(Error,Maybe(HTTP_header)) |
| 1771 | read_header | 1789 | read_header |
| 1772 | ( | 1790 | ( |
| 1773 | - HTTP_BufferedConnection connection | 1791 | + HTTP_Buffered_Connection connection |
| 1774 | ) = | 1792 | ) = |
| 1775 | //Find the name | 1793 | //Find the name |
| 1776 | if read_header_name(connection, []) is | 1794 | if read_header_name(connection, []) is |
| @@ -1811,7 +1829,7 @@ define Result(Error,Maybe(HTTP_header)) | @@ -1811,7 +1829,7 @@ define Result(Error,Maybe(HTTP_header)) | ||
| 1811 | public define Result(Error,List(HTTP_header)) | 1829 | public define Result(Error,List(HTTP_header)) |
| 1812 | read_http_headers | 1830 | read_http_headers |
| 1813 | ( | 1831 | ( |
| 1814 | - HTTP_BufferedConnection connection | 1832 | + HTTP_Buffered_Connection connection |
| 1815 | ) = | 1833 | ) = |
| 1816 | if read_header(connection) is | 1834 | if read_header(connection) is |
| 1817 | { | 1835 | { |
| @@ -1872,7 +1890,7 @@ public define Result(Error,Int) | @@ -1872,7 +1890,7 @@ public define Result(Error,Int) | ||
| 1872 | public define Result(Error, ByteArray) | 1890 | public define Result(Error, ByteArray) |
| 1873 | read_http_body | 1891 | read_http_body |
| 1874 | ( | 1892 | ( |
| 1875 | - HTTP_BufferedConnection connection, | 1893 | + HTTP_Buffered_Connection connection, |
| 1876 | Int body_size, | 1894 | Int body_size, |
| 1877 | ByteArray so_far, // when calling this function, 'so_far' is the empty byte array | 1895 | ByteArray so_far, // when calling this function, 'so_far' is the empty byte array |
| 1878 | Int retries // this function is called with retries = 10 | 1896 | Int retries // this function is called with retries = 10 |
| @@ -2479,8 +2497,8 @@ define One | @@ -2479,8 +2497,8 @@ define One | ||
| 2479 | String host_name, | 2497 | String host_name, |
| 2480 | Web_Site_Description desc, | 2498 | Web_Site_Description desc, |
| 2481 | Connection connection, // with the client | 2499 | Connection connection, // with the client |
| 2482 | - Word32 ip_addr, // of the client | ||
| 2483 | - HTTP_RequestLine request_line, | 2500 | + Word32 ip_addr, // of the client |
| 2501 | + HTTP_Request_Line request_line, | ||
| 2484 | List(HTTP_header) headers, | 2502 | List(HTTP_header) headers, |
| 2485 | ByteArray body, | 2503 | ByteArray body, |
| 2486 | One -> String generate_tt // trust ticket generation | 2504 | One -> String generate_tt // trust ticket generation |
| @@ -2492,13 +2510,15 @@ define One | @@ -2492,13 +2510,15 @@ define One | ||
| 2492 | http_inf = http_info(ip_addr, host_name, uri, headers, is_SSL(connection)), | 2510 | http_inf = http_info(ip_addr, host_name, uri, headers, is_SSL(connection)), |
| 2493 | (if member(journal_extensions(desc),ext) | 2511 | (if member(journal_extensions(desc),ext) |
| 2494 | then log_journal_msg(desc, | 2512 | then log_journal_msg(desc, |
| 2495 | - format_request(desc,connection,request_line,headers,all_web_args)) | 2513 | + format_request(desc, connection, request_line, headers, all_web_args)) |
| 2496 | else unique); | 2514 | else unique); |
| 2497 | - if is_illegal_uri(uri,0) | ||
| 2498 | - then log_journal_msg(desc,"Received illegal URI: "+uri+"\n") | ||
| 2499 | - else (if (ext = ".awp" | ext = "") | 2515 | + |
| 2516 | + if is_illegal_uri(uri,0) then | ||
| 2517 | + log_journal_msg(desc,"Received illegal URI: "+uri+"\n") | ||
| 2518 | + else | ||
| 2519 | + (if (ext = ".awp" | ext = "") | ||
| 2500 | then | 2520 | then |
| 2501 | - if awp_handler(desc)(host_name, http_inf, all_web_args, is_SSL(connection)) is | 2521 | + if desc.awp_handler(host_name, http_inf, all_web_args, is_SSL(connection)) is |
| 2502 | { | 2522 | { |
| 2503 | printable_tree(answer_headers_body) then | 2523 | printable_tree(answer_headers_body) then |
| 2504 | forget(reliable_write(connection, answer_headers_body)), | 2524 | forget(reliable_write(connection, answer_headers_body)), |
| @@ -2982,7 +3002,7 @@ define One | @@ -2982,7 +3002,7 @@ define One | ||
| 2982 | Web_Site_Description desc, | 3002 | Web_Site_Description desc, |
| 2983 | Connection connection, | 3003 | Connection connection, |
| 2984 | Word32 ip_addr, | 3004 | Word32 ip_addr, |
| 2985 | - HTTP_RequestLine request_line, | 3005 | + HTTP_Request_Line request_line, |
| 2986 | List(HTTP_header) headers, | 3006 | List(HTTP_header) headers, |
| 2987 | String body_temp_file, | 3007 | String body_temp_file, |
| 2988 | One -> String generate_tt, | 3008 | One -> String generate_tt, |
| @@ -3261,7 +3281,7 @@ define One | @@ -3261,7 +3281,7 @@ define One | ||
| 3261 | http_https_handler | 3281 | http_https_handler |
| 3262 | ( | 3282 | ( |
| 3263 | List(Web_Site_Description) sites, | 3283 | List(Web_Site_Description) sites, |
| 3264 | - HTTP_BufferedConnection connection, | 3284 | + HTTP_Buffered_Connection connection, |
| 3265 | Bool is_https, | 3285 | Bool is_https, |
| 3266 | DenialOfService dos, | 3286 | DenialOfService dos, |
| 3267 | SState s, | 3287 | SState s, |
| @@ -3295,8 +3315,8 @@ define One | @@ -3295,8 +3315,8 @@ define One | ||
| 3295 | { | 3315 | { |
| 3296 | error(msg) then log_journal_msg(desc,format(msg)), | 3316 | error(msg) then log_journal_msg(desc,format(msg)), |
| 3297 | ok(body_size) then | 3317 | ok(body_size) then |
| 3298 | - if rqline is request_line(type, uri, qstring) then | ||
| 3299 | - with rqline2 = request_line(type, handle_redirection(redirections(desc), uri, headers), qstring), | 3318 | + if rqline is request_line(method, uri, qstring) then |
| 3319 | + with rqline2 = request_line(method, handle_redirection(redirections(desc), uri, headers), qstring), | ||
| 3300 | 3320 | ||
| 3301 | //Get the type of encoding which decide if we read the content in ByteArray for www_url or in | 3321 | //Get the type of encoding which decide if we read the content in ByteArray for www_url or in |
| 3302 | //temporary file for multipart. | 3322 | //temporary file for multipart. |
| @@ -3309,10 +3329,12 @@ define One | @@ -3309,10 +3329,12 @@ define One | ||
| 3309 | { | 3329 | { |
| 3310 | error(msg) then log_journal_msg(desc,format(msg)), | 3330 | error(msg) then log_journal_msg(desc,format(msg)), |
| 3311 | ok(body) then | 3331 | ok(body) then |
| 3332 | + //HERE produce the answer of the server | ||
| 3312 | www_url_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, body, generate_tt); | 3333 | www_url_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, body, generate_tt); |
| 3313 | //it's HTTP 1.1 keep-alive is default | 3334 | //it's HTTP 1.1 keep-alive is default |
| 3314 | http_https_handler(sites, connection, is_https, dos, s, shutdown_required) | 3335 | http_https_handler(sites, connection, is_https, dos, s, shutdown_required) |
| 3315 | } | 3336 | } |
| 3337 | + | ||
| 3316 | //MULTIPART_FORM_DATA | 3338 | //MULTIPART_FORM_DATA |
| 3317 | multipart_form_data then | 3339 | multipart_form_data then |
| 3318 | 3340 |
web/CXM_web_action.anubis
| @@ -68,7 +68,7 @@ public define String | @@ -68,7 +68,7 @@ public define String | ||
| 68 | format_web_action_name | 68 | format_web_action_name |
| 69 | ( | 69 | ( |
| 70 | WEB_Action_Name action, | 70 | WEB_Action_Name action, |
| 71 | - List((String,String)) extra_ops, | 71 | + List((String,String)) extra_ops, |
| 72 | )= | 72 | )= |
| 73 | format_web_action_name(action) | 73 | format_web_action_name(action) |
| 74 | + | 74 | + |
web/CXM_web_session.anubis
| @@ -78,6 +78,7 @@ public type WEB_Request_No_Var: | @@ -78,6 +78,7 @@ public type WEB_Request_No_Var: | ||
| 78 | 78 | ||
| 79 | public type WEB_Session: | 79 | public type WEB_Session: |
| 80 | web_session( | 80 | web_session( |
| 81 | + String session_id, | ||
| 81 | String language, | 82 | String language, |
| 82 | Var(List(WEB_Session_Field)) fields, | 83 | Var(List(WEB_Session_Field)) fields, |
| 83 | WEB_Request web_request, | 84 | WEB_Request web_request, |
| @@ -86,6 +87,7 @@ public type WEB_Session: | @@ -86,6 +87,7 @@ public type WEB_Session: | ||
| 86 | 87 | ||
| 87 | public type WEB_Session_No_Var: | 88 | public type WEB_Session_No_Var: |
| 88 | web_session( | 89 | web_session( |
| 90 | + String session_id, | ||
| 89 | String language, | 91 | String language, |
| 90 | List(WEB_Session_Field_No_Var) fields, | 92 | List(WEB_Session_Field_No_Var) fields, |
| 91 | WEB_Request_No_Var web_request, | 93 | WEB_Request_No_Var web_request, |
| @@ -107,6 +109,14 @@ public define WEB_Session_Field | @@ -107,6 +109,14 @@ public define WEB_Session_Field | ||
| 107 | 109 | ||
| 108 | *----------------------------------------------------------------* | 110 | *----------------------------------------------------------------* |
| 109 | 111 | ||
| 112 | +public define String | ||
| 113 | + get_new_session_id | ||
| 114 | + = | ||
| 115 | + with session_id = (now, (Word32)virtual_machine_id), | ||
| 116 | + to_ascii(sha1(session_id)) | ||
| 117 | +. | ||
| 118 | + | ||
| 119 | + | ||
| 110 | define Var(List(WEB_Session_Field)) | 120 | define Var(List(WEB_Session_Field)) |
| 111 | to_WEB_Session_Field | 121 | to_WEB_Session_Field |
| 112 | ( | 122 | ( |
| @@ -128,8 +138,8 @@ public define WEB_Session | @@ -128,8 +138,8 @@ public define WEB_Session | ||
| 128 | ( | 138 | ( |
| 129 | WEB_Session_No_Var _session | 139 | WEB_Session_No_Var _session |
| 130 | )= | 140 | )= |
| 131 | - since _session is web_session(language, fields, c_web_request, p_web_request), | ||
| 132 | - web_session(language, to_WEB_Session_Field(fields), | 141 | + since _session is web_session(id, language, fields, c_web_request, p_web_request), |
| 142 | + web_session(id, language, to_WEB_Session_Field(fields), | ||
| 133 | web_request(c_web_request.http_info, var(c_web_request.lwa), c_web_request.is_https), | 143 | web_request(c_web_request.http_info, var(c_web_request.lwa), c_web_request.is_https), |
| 134 | web_request(p_web_request.http_info, var(p_web_request.lwa), p_web_request.is_https) | 144 | web_request(p_web_request.http_info, var(p_web_request.lwa), p_web_request.is_https) |
| 135 | ) | 145 | ) |
| @@ -140,8 +150,8 @@ public define WEB_Session_No_Var | @@ -140,8 +150,8 @@ public define WEB_Session_No_Var | ||
| 140 | ( | 150 | ( |
| 141 | WEB_Session _session | 151 | WEB_Session _session |
| 142 | )= | 152 | )= |
| 143 | - since _session is web_session(language, fields, c_web_request, p_web_request), | ||
| 144 | - web_session(language, to_WEB_Session_Field_No_Var(*fields), | 153 | + since _session is web_session(id, language, fields, c_web_request, p_web_request), |
| 154 | + web_session(id, language, to_WEB_Session_Field_No_Var(*fields), | ||
| 145 | web_request(c_web_request.http_info, *c_web_request.lwa, c_web_request.is_https), | 155 | web_request(c_web_request.http_info, *c_web_request.lwa, c_web_request.is_https), |
| 146 | web_request(p_web_request.http_info, *p_web_request.lwa, p_web_request.is_https) | 156 | web_request(p_web_request.http_info, *p_web_request.lwa, p_web_request.is_https) |
| 147 | ) | 157 | ) |
| @@ -1129,10 +1139,11 @@ public define String | @@ -1129,10 +1139,11 @@ public define String | ||
| 1129 | ( | 1139 | ( |
| 1130 | WEB_Session _session | 1140 | WEB_Session _session |
| 1131 | )= | 1141 | )= |
| 1132 | - since _session is web_session(language, fields, web_request, previous_web_request), | 1142 | + since _session is web_session(id, language, fields, web_request, previous_web_request), |
| 1133 | "WEB Session Dump: \n"+ | 1143 | "WEB Session Dump: \n"+ |
| 1134 | "----------------- \n"+ | 1144 | "----------------- \n"+ |
| 1135 | - "Language : ["+language+"]\n\n"+ | 1145 | + "Session ID : ["+id+"]\n"+ |
| 1146 | + "Language : ["+language+"]\n\n"+ | ||
| 1136 | dump_WEB_Session_Fields(*fields)+ | 1147 | dump_WEB_Session_Fields(*fields)+ |
| 1137 | "-----------------------------------------------------------------------------\n"+ | 1148 | "-----------------------------------------------------------------------------\n"+ |
| 1138 | "Current WEB REQUEST:\n"+ | 1149 | "Current WEB REQUEST:\n"+ |
web/jQuery/CXM_jquery_dialog.anubis
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | read system/convert.anubis | 9 | read system/convert.anubis |
| 10 | read calexium_lib/web/CXM_making_a_web_site.anubis | 10 | read calexium_lib/web/CXM_making_a_web_site.anubis |
| 11 | -read calexium_lib/web/CXM_jquery.anubis | 11 | +transmit calexium_lib/web/CXM_jquery.anubis |
| 12 | 12 | ||
| 13 | public type JQuery_dialog_id: | 13 | public type JQuery_dialog_id: |
| 14 | dialog_id(String id). | 14 | dialog_id(String id). |
| @@ -66,9 +66,9 @@ $( \"#"+dlg_id+"\" ).dialog({ | @@ -66,9 +66,9 @@ $( \"#"+dlg_id+"\" ).dialog({ | ||
| 66 | { | 66 | { |
| 67 | p_content(pc) then | 67 | p_content(pc) then |
| 68 | if pc is partial_content(tags, html) then | 68 | if pc is partial_content(tags, html) then |
| 69 | - partial_content( [js . tags ], html), //html code of the dialog | 69 | + partial_content( [js . tags ], div([id(dlg_id)], html)), //html code of the dialog |
| 70 | off_form(html) then | 70 | off_form(html) then |
| 71 | - partial_content( [js], html), //html code of the dialog | 71 | + partial_content( [js], div([id(dlg_id)], html)), //html code of the dialog |
| 72 | ajax(_url) then | 72 | ajax(_url) then |
| 73 | with url = format_web_action_name(_url), | 73 | with url = format_web_action_name(_url), |
| 74 | //println("jq_dialog_create : \njs_str ->"+js_str+"\nurl ->"+url); | 74 | //println("jq_dialog_create : \njs_str ->"+js_str+"\nurl ->"+url); |