Commit 2686174d0477b4a2c4aa77e419833291fff69412
Merge branch 'release/ANUBIS_1_14' of ssh://gitlab.calexium.com:33022/calexium/c…
…alexium_lib into release/ANUBIS_1_14
Showing
3 changed files
with
82 additions
and
59 deletions
Show diff stats
web/CXM_multihost_http_server.anubis
| @@ -685,20 +685,20 @@ type EncodingType: | @@ -685,20 +685,20 @@ type EncodingType: | ||
| 685 | multipart_form_data. | 685 | multipart_form_data. |
| 686 | 686 | ||
| 687 | 687 | ||
| 688 | -type BufferedConnection: | ||
| 689 | - buffered_connection(Connection conn, | 688 | +public type HTTP_BufferedConnection: |
| 689 | + http_buffered_connection(Connection conn, | ||
| 690 | Var(ByteArray) buffer, | 690 | Var(ByteArray) buffer, |
| 691 | Var(Int) read_pos, | 691 | Var(Int) read_pos, |
| 692 | Var(List(Word8)) unput_chars // for reading requests | 692 | Var(List(Word8)) unput_chars // for reading requests |
| 693 | ). | 693 | ). |
| 694 | 694 | ||
| 695 | 695 | ||
| 696 | -define BufferedConnection | ||
| 697 | - buffered_connection | 696 | +public define HTTP_BufferedConnection |
| 697 | + http_buffered_connection | ||
| 698 | ( | 698 | ( |
| 699 | Connection conn | 699 | Connection conn |
| 700 | )= | 700 | )= |
| 701 | - buffered_connection(conn, var(constant_byte_array(0, 0)), var(0), var([])) | 701 | + http_buffered_connection(conn, var(constant_byte_array(0, 0)), var(0), var([])) |
| 702 | . | 702 | . |
| 703 | 703 | ||
| 704 | 704 | ||
| @@ -777,7 +777,7 @@ define One | @@ -777,7 +777,7 @@ define One | ||
| 777 | unput // unputting a character (add it in front of the list) | 777 | unput // unputting a character (add it in front of the list) |
| 778 | ( | 778 | ( |
| 779 | Word8 character, | 779 | Word8 character, |
| 780 | - BufferedConnection s | 780 | + HTTP_BufferedConnection s |
| 781 | ) = | 781 | ) = |
| 782 | s.unput_chars <- (List(Word8))[character . *(s.unput_chars)]. | 782 | s.unput_chars <- (List(Word8))[character . *(s.unput_chars)]. |
| 783 | 783 | ||
| @@ -829,7 +829,7 @@ define One | @@ -829,7 +829,7 @@ define One | ||
| 829 | define ReadResult | 829 | define ReadResult |
| 830 | read_from_connexion | 830 | read_from_connexion |
| 831 | ( | 831 | ( |
| 832 | - BufferedConnection connection, | 832 | + HTTP_BufferedConnection connection, |
| 833 | Int size, | 833 | Int size, |
| 834 | Int time_out, | 834 | Int time_out, |
| 835 | ByteArray result_buffer, | 835 | ByteArray result_buffer, |
| @@ -881,7 +881,7 @@ define Result(Error,Word8) | @@ -881,7 +881,7 @@ define Result(Error,Word8) | ||
| 881 | next_char // reading a character (check the list first, and read on the connection | 881 | next_char // reading a character (check the list first, and read on the connection |
| 882 | // only when the list is empty). | 882 | // only when the list is empty). |
| 883 | ( | 883 | ( |
| 884 | - BufferedConnection connection | 884 | + HTTP_BufferedConnection connection |
| 885 | // Int dead_line, | 885 | // Int dead_line, |
| 886 | // DenialOfService dos | 886 | // DenialOfService dos |
| 887 | ) = | 887 | ) = |
| @@ -937,7 +937,7 @@ define Result(Error,Word8) | @@ -937,7 +937,7 @@ define Result(Error,Word8) | ||
| 937 | define ByteArray | 937 | define ByteArray |
| 938 | get_and_erase_buffer | 938 | get_and_erase_buffer |
| 939 | ( | 939 | ( |
| 940 | - BufferedConnection connection | 940 | + HTTP_BufferedConnection connection |
| 941 | )= | 941 | )= |
| 942 | with head = to_byte_array(implode(*connection.unput_chars)), | 942 | with head = to_byte_array(implode(*connection.unput_chars)), |
| 943 | tail = extract(*connection.buffer, *connection.read_pos, length(*connection.buffer)), | 943 | tail = extract(*connection.buffer, *connection.read_pos, length(*connection.buffer)), |
| @@ -971,7 +971,7 @@ define ByteArray | @@ -971,7 +971,7 @@ define ByteArray | ||
| 971 | define Result(Error,One) | 971 | define Result(Error,One) |
| 972 | read_and_ignore | 972 | read_and_ignore |
| 973 | ( | 973 | ( |
| 974 | - BufferedConnection connection, // to client | 974 | + HTTP_BufferedConnection connection, // to client |
| 975 | Int number_of_characters // number of characters to read and ignore | 975 | Int number_of_characters // number of characters to read and ignore |
| 976 | ) = | 976 | ) = |
| 977 | if number_of_characters =< 0 then | 977 | if number_of_characters =< 0 then |
| @@ -999,7 +999,7 @@ define Result(Error,One) | @@ -999,7 +999,7 @@ define Result(Error,One) | ||
| 999 | define Result(Error,String) | 999 | define Result(Error,String) |
| 1000 | read_string | 1000 | read_string |
| 1001 | ( | 1001 | ( |
| 1002 | - BufferedConnection connection, // connection with the client | 1002 | + HTTP_BufferedConnection connection, // connection with the client |
| 1003 | List(Word8) so_far // characters read so far (in reverse order) | 1003 | List(Word8) so_far // characters read so far (in reverse order) |
| 1004 | ) = | 1004 | ) = |
| 1005 | if next_char(connection) is | 1005 | if next_char(connection) is |
| @@ -1297,34 +1297,36 @@ define Bool | @@ -1297,34 +1297,36 @@ define Bool | ||
| 1297 | Skipping HTTP blanks. | 1297 | Skipping HTTP blanks. |
| 1298 | 1298 | ||
| 1299 | define Result(Error,One) | 1299 | define Result(Error,One) |
| 1300 | - skip_http_blanks | ||
| 1301 | - ( | ||
| 1302 | - BufferedConnection connection | ||
| 1303 | - ) = | ||
| 1304 | - if next_char(connection) is | ||
| 1305 | - { | ||
| 1306 | - error(msg) then error(msg), | ||
| 1307 | - ok(c) then | ||
| 1308 | - if is_strict_blank(c) | ||
| 1309 | - then skip_http_blanks(connection) | ||
| 1310 | - else if c = 13 | 1300 | + skip_http_blanks |
| 1301 | + ( | ||
| 1302 | + HTTP_BufferedConnection connection | ||
| 1303 | + ) | ||
| 1304 | + = | ||
| 1305 | + if next_char(connection) is | ||
| 1306 | + { | ||
| 1307 | + error(msg) then error(msg), | ||
| 1308 | + ok(c) then | ||
| 1309 | + if is_strict_blank(c) | ||
| 1310 | + then skip_http_blanks(connection) | ||
| 1311 | + else if c = 13 | ||
| 1312 | + then if next_char(connection) is | ||
| 1313 | + { | ||
| 1314 | + error(msg) then error(msg), // (unput(c); ok(unique)), | ||
| 1315 | + ok(d) then | ||
| 1316 | + if d = 10 | ||
| 1311 | then if next_char(connection) is | 1317 | then if next_char(connection) is |
| 1312 | { | 1318 | { |
| 1313 | - error(msg) then error(msg), // (unput(c); ok(unique)), | ||
| 1314 | - ok(d) then | ||
| 1315 | - if d = 10 | ||
| 1316 | - then if next_char(connection) is | ||
| 1317 | - { | ||
| 1318 | - error(msg) then error(msg), // (unput(d); unput(c); ok(unique)), | ||
| 1319 | - ok(e) then | ||
| 1320 | - if is_strict_blank(e) | ||
| 1321 | - then skip_http_blanks(connection) | ||
| 1322 | - else (unput(e, connection); unput(d, connection); unput(c, connection); ok(unique)) | ||
| 1323 | - } | ||
| 1324 | - else (unput(d, connection); unput(c, connection); ok(unique)) | 1319 | + error(msg) then error(msg), // (unput(d); unput(c); ok(unique)), |
| 1320 | + ok(e) then | ||
| 1321 | + if is_strict_blank(e) | ||
| 1322 | + then skip_http_blanks(connection) | ||
| 1323 | + else (unput(e, connection); unput(d, connection); unput(c, connection); ok(unique)) | ||
| 1325 | } | 1324 | } |
| 1326 | - else (unput(c, connection); ok(unique)) | ||
| 1327 | - }. | 1325 | + else (unput(d, connection); unput(c, connection); ok(unique)) |
| 1326 | + } | ||
| 1327 | + else (unput(c, connection); ok(unique)) | ||
| 1328 | + } | ||
| 1329 | +. | ||
| 1328 | 1330 | ||
| 1329 | 1331 | ||
| 1330 | 1332 | ||
| @@ -1353,7 +1355,7 @@ define Result(Error,One) | @@ -1353,7 +1355,7 @@ define Result(Error,One) | ||
| 1353 | public define Result(Error,One) | 1355 | public define Result(Error,One) |
| 1354 | read_new_line | 1356 | read_new_line |
| 1355 | ( | 1357 | ( |
| 1356 | - BufferedConnection connection | 1358 | + HTTP_BufferedConnection connection |
| 1357 | ) = | 1359 | ) = |
| 1358 | if skip_http_blanks(connection) is | 1360 | if skip_http_blanks(connection) is |
| 1359 | { | 1361 | { |
| @@ -1384,7 +1386,7 @@ public define Result(Error,One) | @@ -1384,7 +1386,7 @@ public define Result(Error,One) | ||
| 1384 | public define Result(Error,One) | 1386 | public define Result(Error,One) |
| 1385 | skip_line | 1387 | skip_line |
| 1386 | ( | 1388 | ( |
| 1387 | - BufferedConnection connection | 1389 | + HTTP_BufferedConnection connection |
| 1388 | ) = | 1390 | ) = |
| 1389 | if next_char(connection) is | 1391 | if next_char(connection) is |
| 1390 | { | 1392 | { |
| @@ -1423,7 +1425,7 @@ public define Result(Error,One) | @@ -1423,7 +1425,7 @@ public define Result(Error,One) | ||
| 1423 | define Result(Error,String) | 1425 | define Result(Error,String) |
| 1424 | read_word_aux | 1426 | read_word_aux |
| 1425 | ( | 1427 | ( |
| 1426 | - BufferedConnection connection, | 1428 | + HTTP_BufferedConnection connection, |
| 1427 | List(Word8) so_far | 1429 | List(Word8) so_far |
| 1428 | ) = | 1430 | ) = |
| 1429 | if next_char(connection) is | 1431 | if next_char(connection) is |
| @@ -1439,7 +1441,7 @@ define Result(Error,String) | @@ -1439,7 +1441,7 @@ define Result(Error,String) | ||
| 1439 | define Result(Error,String) | 1441 | define Result(Error,String) |
| 1440 | read_word | 1442 | read_word |
| 1441 | ( | 1443 | ( |
| 1442 | - BufferedConnection connection | 1444 | + HTTP_BufferedConnection connection |
| 1443 | ) = | 1445 | ) = |
| 1444 | if skip_http_blanks(connection) is | 1446 | if skip_http_blanks(connection) is |
| 1445 | { | 1447 | { |
| @@ -1613,7 +1615,7 @@ define Result(Error,HTTP_RequestType) | @@ -1613,7 +1615,7 @@ define Result(Error,HTTP_RequestType) | ||
| 1613 | public define Result(Error, HTTP_RequestLine) | 1615 | public define Result(Error, HTTP_RequestLine) |
| 1614 | read_request_line | 1616 | read_request_line |
| 1615 | ( | 1617 | ( |
| 1616 | - BufferedConnection connection | 1618 | + HTTP_BufferedConnection connection |
| 1617 | ) = | 1619 | ) = |
| 1618 | if read_word(connection) is | 1620 | if read_word(connection) is |
| 1619 | { | 1621 | { |
| @@ -1664,7 +1666,7 @@ define Bool | @@ -1664,7 +1666,7 @@ define Bool | ||
| 1664 | define Result(Error,String) | 1666 | define Result(Error,String) |
| 1665 | read_header_name | 1667 | read_header_name |
| 1666 | ( | 1668 | ( |
| 1667 | - BufferedConnection connection, | 1669 | + HTTP_BufferedConnection connection, |
| 1668 | List(Word8) so_far | 1670 | List(Word8) so_far |
| 1669 | ) = | 1671 | ) = |
| 1670 | if next_char(connection) is | 1672 | if next_char(connection) is |
| @@ -1679,7 +1681,7 @@ define Result(Error,String) | @@ -1679,7 +1681,7 @@ define Result(Error,String) | ||
| 1679 | define Result(Error,One) | 1681 | define Result(Error,One) |
| 1680 | skip_colon | 1682 | skip_colon |
| 1681 | ( | 1683 | ( |
| 1682 | - BufferedConnection connection | 1684 | + HTTP_BufferedConnection connection |
| 1683 | ) = | 1685 | ) = |
| 1684 | //Skip the blank char until ':' | 1686 | //Skip the blank char until ':' |
| 1685 | if skip_http_blanks(connection) is | 1687 | if skip_http_blanks(connection) is |
| @@ -1699,7 +1701,7 @@ define Result(Error,One) | @@ -1699,7 +1701,7 @@ define Result(Error,One) | ||
| 1699 | define Result(Error,String) | 1701 | define Result(Error,String) |
| 1700 | read_header_value | 1702 | read_header_value |
| 1701 | ( | 1703 | ( |
| 1702 | - BufferedConnection connection, | 1704 | + HTTP_BufferedConnection connection, |
| 1703 | List(Word8) so_far | 1705 | List(Word8) so_far |
| 1704 | ) = | 1706 | ) = |
| 1705 | if next_char(connection) is | 1707 | if next_char(connection) is |
| @@ -1731,7 +1733,7 @@ define Result(Error,String) | @@ -1731,7 +1733,7 @@ define Result(Error,String) | ||
| 1731 | define Result(Error,Maybe(HTTP_header)) | 1733 | define Result(Error,Maybe(HTTP_header)) |
| 1732 | read_header | 1734 | read_header |
| 1733 | ( | 1735 | ( |
| 1734 | - BufferedConnection connection | 1736 | + HTTP_BufferedConnection connection |
| 1735 | ) = | 1737 | ) = |
| 1736 | //Find the name | 1738 | //Find the name |
| 1737 | if read_header_name(connection, []) is | 1739 | if read_header_name(connection, []) is |
| @@ -1772,7 +1774,7 @@ define Result(Error,Maybe(HTTP_header)) | @@ -1772,7 +1774,7 @@ define Result(Error,Maybe(HTTP_header)) | ||
| 1772 | public define Result(Error,List(HTTP_header)) | 1774 | public define Result(Error,List(HTTP_header)) |
| 1773 | read_http_headers | 1775 | read_http_headers |
| 1774 | ( | 1776 | ( |
| 1775 | - BufferedConnection connection | 1777 | + HTTP_BufferedConnection connection |
| 1776 | ) = | 1778 | ) = |
| 1777 | if read_header(connection) is | 1779 | if read_header(connection) is |
| 1778 | { | 1780 | { |
| @@ -1831,13 +1833,13 @@ public define Result(Error,Int) | @@ -1831,13 +1833,13 @@ public define Result(Error,Int) | ||
| 1831 | make at most 10 retries, with a small sleeping time between any two of them. | 1833 | make at most 10 retries, with a small sleeping time between any two of them. |
| 1832 | 1834 | ||
| 1833 | public define Result(Error, ByteArray) | 1835 | public define Result(Error, ByteArray) |
| 1834 | - read_http_body | ||
| 1835 | - ( | ||
| 1836 | - BufferedConnection connection, | ||
| 1837 | - Int body_size, | ||
| 1838 | - ByteArray so_far, // when calling this function, 'so_far' is the empty byte array | ||
| 1839 | - Int retries // this function is called with retries = 10 | ||
| 1840 | - ) = | 1836 | + read_http_body |
| 1837 | + ( | ||
| 1838 | + HTTP_BufferedConnection connection, | ||
| 1839 | + Int body_size, | ||
| 1840 | + ByteArray so_far, // when calling this function, 'so_far' is the empty byte array | ||
| 1841 | + Int retries // this function is called with retries = 10 | ||
| 1842 | + )= | ||
| 1841 | if body_size = 0 then ok(constant_byte_array(0,0)) else | 1843 | if body_size = 0 then ok(constant_byte_array(0,0)) else |
| 1842 | if retries =< 0 then error(cannot_read_from_connection) else | 1844 | if retries =< 0 then error(cannot_read_from_connection) else |
| 1843 | 1845 | ||
| @@ -3152,7 +3154,7 @@ define One | @@ -3152,7 +3154,7 @@ define One | ||
| 3152 | http_https_handler | 3154 | http_https_handler |
| 3153 | ( | 3155 | ( |
| 3154 | List(Web_Site_Description) sites, | 3156 | List(Web_Site_Description) sites, |
| 3155 | - BufferedConnection connection, | 3157 | + HTTP_BufferedConnection connection, |
| 3156 | Bool is_https, | 3158 | Bool is_https, |
| 3157 | DenialOfService dos, | 3159 | DenialOfService dos, |
| 3158 | SState s, | 3160 | SState s, |
| @@ -3300,7 +3302,7 @@ define Server -> ((RWStream) -> One) | @@ -3300,7 +3302,7 @@ define Server -> ((RWStream) -> One) | ||
| 3300 | if is_dubious_IP(addr,dos) | 3302 | if is_dubious_IP(addr,dos) |
| 3301 | then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n") | 3303 | then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n") |
| 3302 | else | 3304 | else |
| 3303 | - with connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), | 3305 | + with connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), |
| 3304 | http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required). | 3306 | http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required). |
| 3305 | public define One | 3307 | public define One |
| 3306 | http_direct_handler | 3308 | http_direct_handler |
| @@ -3314,7 +3316,7 @@ public define One | @@ -3314,7 +3316,7 @@ public define One | ||
| 3314 | if is_dubious_IP(addr,dos) | 3316 | if is_dubious_IP(addr,dos) |
| 3315 | then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n") | 3317 | then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n") |
| 3316 | else | 3318 | else |
| 3317 | - with connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), | 3319 | + with connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), |
| 3318 | http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required). | 3320 | http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required). |
| 3319 | 3321 | ||
| 3320 | 3322 | ||
| @@ -3326,7 +3328,7 @@ define Server -> (SSL_Connection -> One) | @@ -3326,7 +3328,7 @@ define Server -> (SSL_Connection -> One) | ||
| 3326 | (One) -> Bool shutdown_required | 3328 | (One) -> Bool shutdown_required |
| 3327 | ) = | 3329 | ) = |
| 3328 | (Server server) |-> (SSL_Connection conn) |-> | 3330 | (Server server) |-> (SSL_Connection conn) |-> |
| 3329 | - with connection = buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0), var([])), | 3331 | + with connection = http_buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0), var([])), |
| 3330 | http_https_handler(sites, connection, true, dos, sstate(var(0),var(0)), shutdown_required). | 3332 | http_https_handler(sites, connection, true, dos, sstate(var(0),var(0)), shutdown_required). |
| 3331 | 3333 | ||
| 3332 | 3334 | ||
| @@ -3722,7 +3724,7 @@ define Server -> ((RWStream) -> One) | @@ -3722,7 +3724,7 @@ define Server -> ((RWStream) -> One) | ||
| 3722 | ) = | 3724 | ) = |
| 3723 | (Server server) |-> (RWStream conn) |-> | 3725 | (Server server) |-> (RWStream conn) |-> |
| 3724 | with start_time = (Int)now, | 3726 | with start_time = (Int)now, |
| 3725 | - connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), | 3727 | + connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), |
| 3726 | if read_request_line(connection) is | 3728 | if read_request_line(connection) is |
| 3727 | { | 3729 | { |
| 3728 | error(msg) then print(format(msg)), | 3730 | error(msg) then print(format(msg)), |
web/CXM_xml_rpc.anubis
| @@ -304,7 +304,7 @@ define Maybe(XML_RPC_response) | @@ -304,7 +304,7 @@ define Maybe(XML_RPC_response) | ||
| 304 | )= | 304 | )= |
| 305 | //TODO find the header and content-lenght to get full length of answer | 305 | //TODO find the header and content-lenght to get full length of answer |
| 306 | //construct a buffered connection | 306 | //construct a buffered connection |
| 307 | - with b_con = buffered_connection(conn), | 307 | + with b_con = http_buffered_connection(conn), |
| 308 | if skip_line(b_con) is | 308 | if skip_line(b_con) is |
| 309 | { | 309 | { |
| 310 | error(msg) then print(format(msg));failure, | 310 | error(msg) then print(format(msg));failure, |
web/widgets/left_menu.anubis
| @@ -43,6 +43,16 @@ public define Left_Menu_Entry | @@ -43,6 +43,16 @@ public define Left_Menu_Entry | ||
| 43 | public define Left_Menu_Entry | 43 | public define Left_Menu_Entry |
| 44 | left_menu_entry | 44 | left_menu_entry |
| 45 | ( | 45 | ( |
| 46 | + String entry_id, | ||
| 47 | + String action, | ||
| 48 | + String text | ||
| 49 | + )= | ||
| 50 | + left_menu_entry(entry_id, [], action_name(action), text, []) | ||
| 51 | + . | ||
| 52 | + | ||
| 53 | +public define Left_Menu_Entry | ||
| 54 | + left_menu_entry | ||
| 55 | + ( | ||
| 46 | String entry_id, //it's also use as icon prefix | 56 | String entry_id, //it's also use as icon prefix |
| 47 | WEB_Action_Name action, //action (url to apply when click | 57 | WEB_Action_Name action, //action (url to apply when click |
| 48 | String text, //text to show | 58 | String text, //text to show |
| @@ -50,6 +60,17 @@ public define Left_Menu_Entry | @@ -50,6 +60,17 @@ public define Left_Menu_Entry | ||
| 50 | )= | 60 | )= |
| 51 | left_menu_entry(entry_id, [], action, text, extra) | 61 | left_menu_entry(entry_id, [], action, text, extra) |
| 52 | . | 62 | . |
| 63 | + | ||
| 64 | +public define Left_Menu_Entry | ||
| 65 | + left_menu_entry | ||
| 66 | + ( | ||
| 67 | + String entry_id, //it's also use as icon prefix | ||
| 68 | + String action, //action (url to apply when click | ||
| 69 | + String text, //text to show | ||
| 70 | + List((String, String)) extra //extra web arguments to send when click | ||
| 71 | + )= | ||
| 72 | + left_menu_entry(entry_id, [], action_name(action), text, extra) | ||
| 73 | + . | ||
| 53 | 74 | ||
| 54 | public define Left_Menu_Entry | 75 | public define Left_Menu_Entry |
| 55 | title | 76 | title |