diff --git a/web/CXM_multihost_http_server.anubis b/web/CXM_multihost_http_server.anubis index f07628e..5f21c5c 100644 --- a/web/CXM_multihost_http_server.anubis +++ b/web/CXM_multihost_http_server.anubis @@ -685,20 +685,20 @@ type EncodingType: multipart_form_data. -type BufferedConnection: - buffered_connection(Connection conn, +public type HTTP_BufferedConnection: + http_buffered_connection(Connection conn, Var(ByteArray) buffer, Var(Int) read_pos, Var(List(Word8)) unput_chars // for reading requests ). -define BufferedConnection - buffered_connection +public define HTTP_BufferedConnection + http_buffered_connection ( Connection conn )= - buffered_connection(conn, var(constant_byte_array(0, 0)), var(0), var([])) + http_buffered_connection(conn, var(constant_byte_array(0, 0)), var(0), var([])) . @@ -777,7 +777,7 @@ define One unput // unputting a character (add it in front of the list) ( Word8 character, - BufferedConnection s + HTTP_BufferedConnection s ) = s.unput_chars <- (List(Word8))[character . *(s.unput_chars)]. @@ -829,7 +829,7 @@ define One define ReadResult read_from_connexion ( - BufferedConnection connection, + HTTP_BufferedConnection connection, Int size, Int time_out, ByteArray result_buffer, @@ -881,7 +881,7 @@ define Result(Error,Word8) next_char // reading a character (check the list first, and read on the connection // only when the list is empty). ( - BufferedConnection connection + HTTP_BufferedConnection connection // Int dead_line, // DenialOfService dos ) = @@ -937,7 +937,7 @@ define Result(Error,Word8) define ByteArray get_and_erase_buffer ( - BufferedConnection connection + HTTP_BufferedConnection connection )= with head = to_byte_array(implode(*connection.unput_chars)), tail = extract(*connection.buffer, *connection.read_pos, length(*connection.buffer)), @@ -971,7 +971,7 @@ define ByteArray define Result(Error,One) read_and_ignore ( - BufferedConnection connection, // to client + HTTP_BufferedConnection connection, // to client Int number_of_characters // number of characters to read and ignore ) = if number_of_characters =< 0 then @@ -999,7 +999,7 @@ define Result(Error,One) define Result(Error,String) read_string ( - BufferedConnection connection, // connection with the client + HTTP_BufferedConnection connection, // connection with the client List(Word8) so_far // characters read so far (in reverse order) ) = if next_char(connection) is @@ -1297,34 +1297,36 @@ define Bool Skipping HTTP blanks. define Result(Error,One) - skip_http_blanks - ( - BufferedConnection connection - ) = - if next_char(connection) is - { - error(msg) then error(msg), - ok(c) then - if is_strict_blank(c) - then skip_http_blanks(connection) - else if c = 13 + skip_http_blanks + ( + HTTP_BufferedConnection connection + ) + = + if next_char(connection) is + { + error(msg) then error(msg), + ok(c) then + if is_strict_blank(c) + then skip_http_blanks(connection) + else if c = 13 + then if next_char(connection) is + { + error(msg) then error(msg), // (unput(c); ok(unique)), + ok(d) then + if d = 10 then if next_char(connection) is { - error(msg) then error(msg), // (unput(c); ok(unique)), - ok(d) then - if d = 10 - then if next_char(connection) is - { - error(msg) then error(msg), // (unput(d); unput(c); ok(unique)), - ok(e) then - if is_strict_blank(e) - then skip_http_blanks(connection) - else (unput(e, connection); unput(d, connection); unput(c, connection); ok(unique)) - } - else (unput(d, connection); unput(c, connection); ok(unique)) + error(msg) then error(msg), // (unput(d); unput(c); ok(unique)), + ok(e) then + if is_strict_blank(e) + then skip_http_blanks(connection) + else (unput(e, connection); unput(d, connection); unput(c, connection); ok(unique)) } - else (unput(c, connection); ok(unique)) - }. + else (unput(d, connection); unput(c, connection); ok(unique)) + } + else (unput(c, connection); ok(unique)) + } +. @@ -1353,7 +1355,7 @@ define Result(Error,One) public define Result(Error,One) read_new_line ( - BufferedConnection connection + HTTP_BufferedConnection connection ) = if skip_http_blanks(connection) is { @@ -1384,7 +1386,7 @@ public define Result(Error,One) public define Result(Error,One) skip_line ( - BufferedConnection connection + HTTP_BufferedConnection connection ) = if next_char(connection) is { @@ -1423,7 +1425,7 @@ public define Result(Error,One) define Result(Error,String) read_word_aux ( - BufferedConnection connection, + HTTP_BufferedConnection connection, List(Word8) so_far ) = if next_char(connection) is @@ -1439,7 +1441,7 @@ define Result(Error,String) define Result(Error,String) read_word ( - BufferedConnection connection + HTTP_BufferedConnection connection ) = if skip_http_blanks(connection) is { @@ -1613,7 +1615,7 @@ define Result(Error,HTTP_RequestType) public define Result(Error, HTTP_RequestLine) read_request_line ( - BufferedConnection connection + HTTP_BufferedConnection connection ) = if read_word(connection) is { @@ -1664,7 +1666,7 @@ define Bool define Result(Error,String) read_header_name ( - BufferedConnection connection, + HTTP_BufferedConnection connection, List(Word8) so_far ) = if next_char(connection) is @@ -1679,7 +1681,7 @@ define Result(Error,String) define Result(Error,One) skip_colon ( - BufferedConnection connection + HTTP_BufferedConnection connection ) = //Skip the blank char until ':' if skip_http_blanks(connection) is @@ -1699,7 +1701,7 @@ define Result(Error,One) define Result(Error,String) read_header_value ( - BufferedConnection connection, + HTTP_BufferedConnection connection, List(Word8) so_far ) = if next_char(connection) is @@ -1731,7 +1733,7 @@ define Result(Error,String) define Result(Error,Maybe(HTTP_header)) read_header ( - BufferedConnection connection + HTTP_BufferedConnection connection ) = //Find the name if read_header_name(connection, []) is @@ -1772,7 +1774,7 @@ define Result(Error,Maybe(HTTP_header)) public define Result(Error,List(HTTP_header)) read_http_headers ( - BufferedConnection connection + HTTP_BufferedConnection connection ) = if read_header(connection) is { @@ -1831,13 +1833,13 @@ public define Result(Error,Int) make at most 10 retries, with a small sleeping time between any two of them. public define Result(Error, ByteArray) - read_http_body - ( - BufferedConnection connection, - Int body_size, - ByteArray so_far, // when calling this function, 'so_far' is the empty byte array - Int retries // this function is called with retries = 10 - ) = + read_http_body + ( + HTTP_BufferedConnection connection, + Int body_size, + ByteArray so_far, // when calling this function, 'so_far' is the empty byte array + Int retries // this function is called with retries = 10 + )= if body_size = 0 then ok(constant_byte_array(0,0)) else if retries =< 0 then error(cannot_read_from_connection) else @@ -3152,7 +3154,7 @@ define One http_https_handler ( List(Web_Site_Description) sites, - BufferedConnection connection, + HTTP_BufferedConnection connection, Bool is_https, DenialOfService dos, SState s, @@ -3300,7 +3302,7 @@ define Server -> ((RWStream) -> One) if is_dubious_IP(addr,dos) then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n") else - with connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), + with connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required). public define One http_direct_handler @@ -3314,7 +3316,7 @@ public define One if is_dubious_IP(addr,dos) then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n") else - with connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), + with connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required). @@ -3326,7 +3328,7 @@ define Server -> (SSL_Connection -> One) (One) -> Bool shutdown_required ) = (Server server) |-> (SSL_Connection conn) |-> - with connection = buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0), var([])), + with connection = http_buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0), var([])), http_https_handler(sites, connection, true, dos, sstate(var(0),var(0)), shutdown_required). @@ -3722,7 +3724,7 @@ define Server -> ((RWStream) -> One) ) = (Server server) |-> (RWStream conn) |-> with start_time = (Int)now, - connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), + connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), if read_request_line(connection) is { error(msg) then print(format(msg)), diff --git a/web/CXM_xml_rpc.anubis b/web/CXM_xml_rpc.anubis index 1e48373..cb8cd40 100644 --- a/web/CXM_xml_rpc.anubis +++ b/web/CXM_xml_rpc.anubis @@ -304,7 +304,7 @@ define Maybe(XML_RPC_response) )= //TODO find the header and content-lenght to get full length of answer //construct a buffered connection - with b_con = buffered_connection(conn), + with b_con = http_buffered_connection(conn), if skip_line(b_con) is { error(msg) then print(format(msg));failure, diff --git a/web/widgets/left_menu.anubis b/web/widgets/left_menu.anubis index 4831615..fe85e5b 100644 --- a/web/widgets/left_menu.anubis +++ b/web/widgets/left_menu.anubis @@ -43,6 +43,16 @@ public define Left_Menu_Entry public define Left_Menu_Entry left_menu_entry ( + String entry_id, + String action, + String text + )= + left_menu_entry(entry_id, [], action_name(action), text, []) + . + +public define Left_Menu_Entry + left_menu_entry + ( String entry_id, //it's also use as icon prefix WEB_Action_Name action, //action (url to apply when click String text, //text to show @@ -50,6 +60,17 @@ public define Left_Menu_Entry )= left_menu_entry(entry_id, [], action, text, extra) . + +public define Left_Menu_Entry + left_menu_entry + ( + String entry_id, //it's also use as icon prefix + String action, //action (url to apply when click + String text, //text to show + List((String, String)) extra //extra web arguments to send when click + )= + left_menu_entry(entry_id, [], action_name(action), text, extra) + . public define Left_Menu_Entry title -- libgit2 0.21.4