From b45f24136385664d0d0a0d1e4b9e5e7b0ce7323f Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 29 Sep 2013 18:21:45 +0200 Subject: [PATCH] Update to be compliant with Anubis 1.13 where the global variable doesn't exist anymore --- net_services/CXM_generic_client.anubis | 2 +- web/CXM_cookies.anubis | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------- web/CXM_making_a_web_site.anubis | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------- web/CXM_multihost_http_server.anubis | 295 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------ 4 files changed, 377 insertions(+), 276 deletions(-) diff --git a/net_services/CXM_generic_client.anubis b/net_services/CXM_generic_client.anubis index ee16108..8a4d531 100644 --- a/net_services/CXM_generic_client.anubis +++ b/net_services/CXM_generic_client.anubis @@ -185,7 +185,7 @@ public define Maybe($T) = if connect( server, port) is { - error(_) then logger(queue_name + ": Can't connect to domain manager ["+ip_addr_to_string(server)+":"+port+"]");failure, + error(_) then logger(queue_name + ": Can't connect to service ["+ip_addr_to_string(server)+":"+port+"]");failure, ok(conn) then // println("[" + virtual_machine_id + "] netservices create queue"); with queue = create_MessageQueue(queue_name), diff --git a/web/CXM_cookies.anubis b/web/CXM_cookies.anubis index 8581aab..e4db40b 100644 --- a/web/CXM_cookies.anubis +++ b/web/CXM_cookies.anubis @@ -192,14 +192,22 @@ public type Atom: semi_colon. -variable List(Atom) unput_atoms = []. + variable List(Atom) unput_atoms = []. + +type CookieToolBox: + tool_box(Var(List(Atom)) unput_atoms, + Var(String) input, + Var(Int) index, + Var(String) server_name + ). define One unput_atom ( - Atom a + CookieToolBox tbx, + Atom a ) = - unput_atoms <- [a . *unput_atoms]. + unput_atoms(tbx) <- [a . *unput_atoms(tbx)]. define Atom recognize_keyword @@ -216,12 +224,15 @@ define Atom token(s). -variable String input = "". From which cookies will be read. -variable Int index = 0. Current position within 'input'. + variable String input = "". From which cookies will be read. + variable Int index = 0. Current position within 'input'. define Maybe(Word8) next_char - = + ( + CookieToolBox tbx + ) = + if tbx is tool_box(_, input, index, _) then if nth(*index,*input) is { failure then failure, @@ -232,36 +243,41 @@ define Maybe(Word8) define One unput_char - = + ( + CookieToolBox tbx + ) = + if tbx is tool_box(_, _, index, _) then index <- *index-1. define Atom read_token ( + CookieToolBox tbx, List(Word8) so_far, // contains at least 1 character (Word8) -> Bool is_valid_char ) = - if next_char is + if next_char(tbx) is { failure then recognize_keyword(implode(reverse(so_far))), success(c) then if is_valid_char(c) - then read_token([c . so_far], is_valid_char) - else unput_char; recognize_keyword(implode(reverse(so_far))) + then read_token(tbx,[c . so_far], is_valid_char) + else unput_char(tbx); recognize_keyword(implode(reverse(so_far))) }. define Atom read_quoted_string ( - List(Word8) so_far + CookieToolBox tbx, + List(Word8) so_far ) = - if next_char is + if next_char(tbx) is { failure then quoted_string(implode(reverse(so_far))), success(c) then if c = '\"' then quoted_string(implode(reverse(so_far))) - else read_quoted_string([c . so_far]) + else read_quoted_string(tbx,[c . so_far]) }. define Bool @@ -275,44 +291,48 @@ define Bool define Atom read_atom - = - if *unput_atoms is + ( + CookieToolBox tbx, + ) = + if *unput_atoms(tbx) is { [ ] then - if next_char is + if next_char(tbx) is { failure then end_of_input, success(c) then - if is_blank(c) then read_atom else // skip blanks - if is_token_char(c) then read_token([c], is_token_char) else - if c = '\"' then read_quoted_string([]) else + if is_blank(c) then read_atom(tbx) else // skip blanks + if is_token_char(c) then read_token(tbx,[c], is_token_char) else + if c = '\"' then read_quoted_string(tbx,[]) else if c = '=' then equals else if c = ':' then colon else if c = ';' then semi_colon else error }, [h . t] then - unput_atoms <- t; h + unput_atoms(tbx) <- t; h }. define Atom read_value - = - if *unput_atoms is + ( + CookieToolBox tbx + ) = + if *unput_atoms(tbx) is { [ ] then - if next_char is + if next_char(tbx) is { failure then end_of_input, success(c) then - if is_blank(c) then read_value else // skip blanks - if is_value_char(c) then read_token([c], is_value_char) else - if c = '\"' then read_quoted_string([]) else - if c = ';' then semi_colon else + if is_blank(c) then read_value(tbx) else // skip blanks + if is_value_char(c) then read_token(tbx,[c], is_value_char) else + if c = '\"' then read_quoted_string(tbx,[]) else + if c = ';' then semi_colon else error }, [h . t] then - unput_atoms <- t; h + unput_atoms(tbx) <- t; h }. Reading an attribute-value pair. @@ -327,38 +347,42 @@ type AttrVal: define String read_eq_value - = - with e = read_atom, + ( + CookieToolBox tbx + ) = + with e = read_atom(tbx), if e is equals then ( - with a = read_atom, + with a = read_atom(tbx), if a is token(n) then n else if a is quoted_string(s) then s else - unput_atom(a); "" + unput_atom(tbx,a); "" ) - else unput_atom(e); "". + else unput_atom(tbx,e); "". define Maybe(AttrVal) read_attr_val - = - if read_atom is semi_colon then - with a = read_atom, + ( + CookieToolBox tbx + ) = + if read_atom(tbx) is semi_colon then + with a = read_atom(tbx), if a is { end_of_input then failure, error then failure, - comment then success(comment(read_eq_value)), - domain then success(domain(read_eq_value)), - max_age then success(max_age(read_eq_value)), - path then success(path(read_eq_value)), + comment then success(comment(read_eq_value(tbx))), + domain then success(domain(read_eq_value(tbx))), + max_age then success(max_age(read_eq_value(tbx))), + path then success(path(read_eq_value(tbx))), secure then success(secure), - version then success(version(read_eq_value)), - token(_) then unput_atom(a); failure, - quoted_string(_) then unput_atom(a); failure, - equals then unput_atom(a); failure, - colon then unput_atom(a); failure, - semi_colon then unput_atom(a); failure, + version then success(version(read_eq_value(tbx))), + token(_) then unput_atom(tbx,a); failure, + quoted_string(_) then unput_atom(tbx,a); failure, + equals then unput_atom(tbx,a); failure, + colon then unput_atom(tbx,a); failure, + semi_colon then unput_atom(tbx,a); failure, } else failure. @@ -454,20 +478,21 @@ define Int Reading a cookie: -variable String server_name = "". + variable String server_name = "". define Maybe(Cookie) read_cookie_n_e_v ( - String name, - String value, - List(AttrVal) so_far + CookieToolBox tbx, + String name, + String value, + List(AttrVal) so_far ) = - if read_attr_val is + if read_attr_val(tbx) is { failure then success(cookie( - *server_name, + *server_name(tbx), name, value, get_comment(so_far), @@ -478,49 +503,53 @@ define Maybe(Cookie) get_version(so_far) )), - success(av) then read_cookie_n_e_v(name,value,[av . so_far]) + success(av) then read_cookie_n_e_v(tbx,name,value,[av . so_far]) }. define Maybe(Cookie) read_cookie_n_e ( - String name + CookieToolBox tbx, + String name ) = - with a = read_value, - - if a is token(value) then read_cookie_n_e_v(name,value,[]) else - if a is quoted_string(value) then read_cookie_n_e_v(name,value,[]) else - unput_atom(a); failure. + with a = read_value(tbx), + if a is token(value) then read_cookie_n_e_v(tbx,name,value,[]) else + if a is quoted_string(value) then read_cookie_n_e_v(tbx,name,value,[]) else + unput_atom(tbx,a); failure. define Maybe(Cookie) read_cookie_n ( - String name + CookieToolBox tbx, // bis repetita placent + String name ) = - with a = read_atom, + with a = read_atom(tbx), if a is equals - then read_cookie_n_e(name) - else unput_atom(a); failure. + then read_cookie_n_e(tbx,name) + else unput_atom(tbx,a); failure. define Maybe(Cookie) read_cookie - = - with a = read_atom, + ( + CookieToolBox tbx + ) = + with a = read_atom(tbx), if a is token(name) - then read_cookie_n(name) - else unput_atom(a); failure. + then read_cookie_n(tbx,name) + else unput_atom(tbx,a); failure. define List(Cookie) read_cookies ( - List(Cookie) so_far + CookieToolBox tbx, + List(Cookie) so_far ) = - if read_cookie is + if read_cookie(tbx) is { failure then so_far, - success(c) then read_cookies([c . so_far]) + success(c) then read_cookies(tbx,[c . so_far]) }. @@ -531,14 +560,8 @@ define List(Cookie) HTTP_header h ) = if h is http_header(n,v) then - if to_lower(n) = "set-cookie" - then ( - unput_atoms <- []; - input <- v; - index <- 0; - server_name <- svn; - read_cookies([]) - ) + if to_lower(n) = "set-cookie" + then read_cookies(tool_box(var([]),var(v),var(0),var(svn)),[]) else []. public define List(Cookie) @@ -561,13 +584,7 @@ define List(Cookie) ) = if h is http_header(n,v) then if to_lower(n) = "cookie" - then ( - unput_atoms <- []; - input <- v; - index <- 0; - server_name <- ""; - read_cookies([]) - ) + then read_cookies(tool_box(var([]),var(v),var(0),var("")),[]) else []. public define List(Cookie) diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index 15c50b8..ea766e4 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -46,13 +46,14 @@ read tools/basis.anubis read tools/printable_tree.anubis +read tools/base64.anubis read system/string.anubis read system/logger.anubis read CXM_common.anubis read CXM_multihost_http_server.anubis read web/mime.anubis read CXM_cookies.anubis - + * (1) Structure of a web site. @@ -2475,7 +2476,50 @@ public define Web_Site //using_state_cookies ), delete_out_of_date). - + +define String + _random_string + ( + Int size, + String current + )= + if size = 0 then + current + else + _random_string( size - 1, current + random(9)) + . + +public define String + generate_random_string + ( + Int size + ) = + to_string(extract(base64_encode(to_byte_array(_random_string(size, ""))), 0, size)). + + +define String + get_site_uid + ( + String site_path + )= + with file_name = site_path+"/site_UID", + if read_from_file(file_name) is + { + cannot_find_file then + println("site UID doesn't exists. Generating it now"); + with uid = generate_random_string(9), + if write_to_file(file_name, to_byte_array(uid)) is + { + cannot_open_file then println("Can't create site UID here "+file_name);"", + write_error(_) then println("Can't write site UID here "+file_name);"", + ok then uid + } + read_error(_) then + println("cannot read site UID from "+file_name);"" + ok(ba) then to_string(ba) + } + . + // Compatibility function for older websites public define Web_Site make_web_site_description @@ -2511,7 +2555,10 @@ public define Web_Site //Bool using_state_cookies ) = - make_web_site_description("", common_names, site_directory, state_directory, init, initial_state, ticket_expired_state, ticket_lost_state, actions, compute_page, additional_headers, timeout, redirections, charset, journal_extensions, journal_headers, secret, known_mime_types, before_send_file) + //generate an unique ID if doesn't exist in root of site_directory + with site_UID = get_site_uid(site_directory), + println("site_UID : "+site_UID); + make_web_site_description(site_UID, common_names, site_directory, state_directory, init, initial_state, ticket_expired_state, ticket_lost_state, actions, compute_page, additional_headers, timeout, redirections, charset, journal_extensions, journal_headers, secret, known_mime_types, before_send_file) . @@ -2984,15 +3031,16 @@ public define Printable_tree }. - -variable Int count = 0. - + Note: this counter is private to the virtual machine, hence there is one counter by client and by page : it seems that a new VM (simply a delegate) is started for each request. define Int new_count - = + ( + Var(Int) count + ) + = count <- *count+1; *count. @@ -3069,14 +3117,15 @@ define URL_or_JavaScript String the_url, Actioner_Aspect aspect, Maybe(String) mb_id, - Maybe(String) mb_form_name + Maybe(String) mb_form_name, + Var(Int) action_count ) = if mb_form_name is { failure then url(the_url), success(form_name) then - with n = new_count, + with n = new_count(action_count), fn_name = "pfu_" + if mb_id is { failure then form_name + "_" + n, @@ -3411,11 +3460,12 @@ define Printable_tree List(Actioner_Local_Action) local_actions, Maybe(String) mb_form_name, Bool is_https, + Var(Int) action_count ) = if cinfo is info(common_name,http_port,https_port,site_dir,secret) then with url = make_actioner_url(cinfo,connection,target, state_name,action_name,extra_ops,is_https), - with action = format_action(url, aspect, extract_id(aspect), mb_form_name), + with action = format_action(url, aspect, extract_id(aspect), mb_form_name, action_count), if aspect is { @@ -3997,10 +4047,11 @@ define Printable_tree ( CommonInfo cinfo, String sn, // state_name - Var(Int) ic_v, + Var(Int) ic_v, HTML_Any($T) element, $T -> Printable_tree format_element, // able to format a datum of type $T Bool is_https, + Var(Int) action_count ) = if cinfo is info(common_name,http_port,https_port,site_directory,secret) then if element is @@ -4044,7 +4095,7 @@ define Printable_tree "secondary document", ""], any_actioner(c,t,a,an,eo,ja,fn) then - format_actioner(cinfo,sn,c,t,a,an,eo,ja,fn,is_https), + format_actioner(cinfo,sn,c,t,a,an,eo,ja,fn,is_https, action_count), any_foreign_link_new(target, aspect, url) then format_foreign_link(target, aspect, url, is_https), @@ -4085,47 +4136,48 @@ define Printable_tree CommonInfo cinfo, String fn, // form_name String sn, // state_name - Var(Int) ic_v, // idnum counter variable + Var(Int) ic_v, // idnum counter variable HTML_In_Form element, Bool is_https, + Var(Int) action_count ) = if cinfo is info(common_name,http_port,https_port,site_directory,secret) then - with format_element = (HTML_In_Form e) |-> format(cinfo,fn,sn,ic_v,e,is_https), + with format_element = (HTML_In_Form e) |-> format(cinfo, fn, sn, ic_v, e, is_https, action_count), if element is { literal_pt(t) then t, literal(t) then [t], sequence(l) then flat(map(format_element,l)) text(opts,t) then - format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https), + format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https, action_count), preformated(o,s) then - format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https), + format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https, action_count), paragraph(opts,t) then - format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https), + format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https, action_count), image(opts, url, alt) then - format(cinfo,sn,ic_v,any_image(opts, url, alt),format_element,is_https), + format(cinfo,sn,ic_v,any_image(opts, url, alt),format_element,is_https, action_count), image(opts, url, alt, w, h) then - format(cinfo,sn,ic_v,any_image(opts, url, alt, w, h),format_element,is_https), + format(cinfo,sn,ic_v,any_image(opts, url, alt, w, h),format_element,is_https, action_count), table(opts,header_row,rows,footer_row) then - format(cinfo,sn,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https), + format(cinfo,sn,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https, action_count), center(e) then - format(cinfo,sn,ic_v,any_center(e),format_element,is_https), + format(cinfo,sn,ic_v,any_center(e),format_element,is_https, action_count), mail_to(a,e) then - format(cinfo,sn,ic_v,any_mail_to(a,e),format_element,is_https), + format(cinfo,sn,ic_v,any_mail_to(a,e),format_element,is_https, action_count), scroller(w,h,cw,ch,c) then - format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https), + format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count), actioner(c,t,a,an,eo,ja) then - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https), + format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count), foreign_link_new(target, aspect, url) then - format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https), + format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count), foreign_link(options,url) then - format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https), + format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https, action_count), foreign_link(options,url,name) then - format(cinfo,sn,ic_v,any_foreign_link(options,url,name),format_element,is_https), + format(cinfo,sn,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count), private_download(url,name,extra,action) then - format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https), + format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count), text_input(options, label_text, id, name, i, w) then [ maybe_label(label_text, id), ""], @@ -4166,9 +4218,9 @@ define Printable_tree [ "", maybe_label(label_text, id)] div(options, e) then - format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https), + format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https, action_count), div_empty(options) then - format(cinfo,sn,ic_v,any_div_empty(options),format_element,is_https), + format(cinfo,sn,ic_v,any_div_empty(options),format_element,is_https, action_count), hidden(id, name, value) then [""], @@ -4273,53 +4325,54 @@ define Printable_tree Var(Int) ic_v, // 'idnum' counter variable HTML_Off_Form element, Bool is_https, + Var(Int) action_count ) = if cinfo is info(common_name,http_port,https_port,site_directory,secret) then - with format_element = (HTML_Off_Form e) |-> format(cinfo,sn,ic_v,e,is_https), + with format_element = (HTML_Off_Form e) |-> format(cinfo, sn, ic_v, e, is_https, action_count), if element is { literal_pt(t) then t, literal(t) then [t], sequence(l) then flat(map(format_element,l)), text(opts,t) then - format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https), + format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https, action_count), preformated(o,s) then - format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https), + format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https, action_count), paragraph(opts,t) then - format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https), + format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https, action_count), image(opts,url,alt) then - format(cinfo,sn,ic_v,any_image(opts,url,alt),format_element,is_https), + format(cinfo,sn,ic_v,any_image(opts,url,alt),format_element,is_https, action_count), image(opts,url,alt,w,h) then - format(cinfo,sn,ic_v,any_image(opts,url,alt,w,h),format_element,is_https), + format(cinfo,sn,ic_v,any_image(opts,url,alt,w,h),format_element,is_https, action_count), table(opts,header_row, rows, footer_row) then - format(cinfo,sn,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https), + format(cinfo,sn,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https, action_count), center(e) then - format(cinfo,sn,ic_v,any_center(e),format_element,is_https), + format(cinfo,sn,ic_v,any_center(e),format_element,is_https, action_count), mail_to(a,e) then - format(cinfo,sn,ic_v,any_mail_to(a,e),format_element,is_https), + format(cinfo,sn,ic_v,any_mail_to(a,e),format_element,is_https, action_count), scroller(w,h,cw,ch,c) then - format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https), + format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count), fixed_size(w,h,c) then - format(cinfo,sn,ic_v,any_fixed_size(w,h,c),format_element,is_https), + format(cinfo,sn,ic_v,any_fixed_size(w,h,c),format_element,is_https, action_count), fixed_size_2(w,h,fn) then - format(cinfo,sn,ic_v,any_fixed_size_2(w,h,fn),format_element,is_https), + format(cinfo,sn,ic_v,any_fixed_size_2(w,h,fn),format_element,is_https, action_count), actioner(c,t,a,an,eo,ja) then - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https), + format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https, action_count), actioner(c,t,a,an,eo,ja,fn) then - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https), + format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count), foreign_link_new(target, aspect, url) then - format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https), + format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count), foreign_link(options,url) then - format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https), + format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https, action_count), foreign_link(options,url,name) then - format(cinfo,sn,ic_v,any_foreign_link(options,url,name),format_element,is_https), + format(cinfo,sn,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count), private_download(url,name,extra,action) then - format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https), + format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count), label(n) then [""], form(fn,attributs, c) then [ "
" ] form(fn,attributs, action_name, extra_ops, c) then @@ -4336,7 +4389,7 @@ define Printable_tree sn, action_name, extra_ops, is_https), [ "", @@ -4346,13 +4399,13 @@ define Printable_tree // action is set dynamically by // the actioner using JavaScript if fn is htmlId(id) then - format(cinfo,id,sn,ic_v,c,is_https), + format(cinfo,id,sn,ic_v,c,is_https, action_count), "
" ] div(options, e) then - format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https), + format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https, action_count), div_empty(options) then - format(cinfo,sn,ic_v,any_div_empty(options),format_element,is_https), + format(cinfo,sn,ic_v,any_div_empty(options),format_element,is_https, action_count), iframe(options, css_styles, css_files, js_files, body) then if body is body(body_options,element) then [ "\n", @@ -4363,7 +4416,7 @@ define Printable_tree add_js_files(js_files), "\n", "\n", // format body options - format(cinfo,sn,ic_v,element,is_https), + format(cinfo,sn,ic_v,element,is_https, action_count), "\n", "\n", "\n", @@ -4524,7 +4577,7 @@ define Printable_tree "\n", format_html_head(head_tags, charset),"\n", "", // format body options - format(cinfo,state_name,ic_v,element,is_https), + format(cinfo,state_name,ic_v,element,is_https, var(0)), "\n", ""], @@ -4565,7 +4618,7 @@ define Printable_tree "\n", "", // format body options //"
", - format(cinfo,state_name,ic_v,element,is_https), + format(cinfo,state_name,ic_v,element,is_https, var(0)), //"
", "\n", "" @@ -4627,7 +4680,7 @@ define Printable_tree html_content(HTTP_Status status, HTML_Off_Form content_HTML) then if format(status) is (status_string, status_headers) then - with content = format(cinfo, state_name, ic_v, content_HTML, is_https), + with content = format(cinfo, state_name, ic_v, content_HTML, is_https, var(0)), [ "HTTP/1.1 " + status_string, crlf, format_headers(standard_headers), format_headers(standard_headers_for("text/html", length(content), success(charset))), diff --git a/web/CXM_multihost_http_server.anubis b/web/CXM_multihost_http_server.anubis index 8448cae..4570c25 100644 --- a/web/CXM_multihost_http_server.anubis +++ b/web/CXM_multihost_http_server.anubis @@ -563,10 +563,10 @@ define String to_decimal(t.seconds) + "." + zero_pad_n(6, t.microseconds ) + "s". -variable UTime t0 = utime(0,0). -variable UTime t1 = utime(0,0). + variable UTime t0 = utime(0,0). + variable UTime t1 = utime(0,0). -define One + define One accumulate_t1 ( UTime start @@ -575,9 +575,9 @@ define One t1 <- delta + *t1; unique. -variable UTime t2 = utime(0,0). + variable UTime t2 = utime(0,0). -define One + define One accumulate_t2 ( UTime start @@ -587,7 +587,7 @@ define One unique. -public define One + public define One print_delta ( String txt @@ -744,12 +744,18 @@ define String + *** [2.3] A set of state variables for the server. +type SState: + sstate + ( + Var(List(Word8)) unput_chars, // for reading requests + Var(Int) sttm, // 'start time' + Var(Int) uploaded_file_count + ). + - - - - *** [2.3] Reading and unputting characters. + *** [2.4] Reading and unputting characters. We need a mecanism for unputting several characters (actually at least 3). This is because when reading the client connection, we must sometimes go ahead several @@ -758,7 +764,7 @@ define String (hold by the variable 'unput_chars'), and we manage this list, so that characters may be virtually put back in the connection (this is called 'unputting'). -variable List(Word8) unput_chars = []. + variable List(Word8) unput_chars = []. The most recently read one is the head of list. Fortunately, this variable is private to this virtual machine (hence to this client). @@ -767,15 +773,16 @@ variable List(Word8) unput_chars = []. define One unput // unputting a character (add it in front of the list) ( - Word8 character + Word8 character, + SState s ) = - unput_chars <- (List(Word8))[character . *unput_chars]. + s.unput_chars <- (List(Word8))[character . *(s.unput_chars)]. define One record_dubious_IP(Word32 addr,DenialOfService dos). -variable Int sttm = 0. // contains the start time for this connection. + variable Int sttm = 0. // contains the start time for this connection. define Result(Error,Word8) record_dubious_connection @@ -783,11 +790,12 @@ define Result(Error,Word8) Connection conn, Int dead_line, DenialOfService dos, + SState s ) = if remote_IP_address_and_port(conn) is (addr,port) then record_dubious_IP(addr,dos); print("Recording IP address "+ip_addr_to_string(addr)+ - " as dubious after "+(dead_line-*sttm)+" seconds. Total: "+ + " as dubious after "+(dead_line-*(s.sttm))+" seconds. Total: "+ length(*list_of_dubious(dos))+"\n"); error(timeout(dead_line)). @@ -866,10 +874,11 @@ define Result(Error,Word8) ( BufferedConnection connection, Int dead_line, - DenialOfService dos + DenialOfService dos, + SState s ) = //with t2_tmp = (UTime) now, - if *unput_chars is + if *(s.unput_chars) is { [ ] then // /////////////////// @@ -913,7 +922,7 @@ define Result(Error,Word8) // }, [h . t] then - unput_chars <- t; //accumulate_t2(t2_tmp); + s.unput_chars <- t; //accumulate_t2(t2_tmp); ok(h) }. @@ -934,13 +943,14 @@ define Result(Error,One) BufferedConnection connection, // to client Int dead_line, Int number_of_characters, // number of characters to read and ignore - DenialOfService dos + DenialOfService dos, + SState s ) = if number_of_characters =< 0 then ok(unique) else - if next_char(connection, dead_line, dos) is + if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), - ok(c) then read_and_ignore(connection,dead_line,number_of_characters-1,dos) + ok(c) then read_and_ignore(connection,dead_line,number_of_characters-1,dos, s) }. @@ -961,25 +971,26 @@ define Result(Error,String) ( BufferedConnection connection, // connection with the client Int dead_line, - List(Word8) so_far, // characters read so far (in reverse order) - DenialOfService dos + List(Word8) so_far, // characters read so far (in reverse order) + DenialOfService dos, + SState s ) = - if next_char(connection, dead_line,dos) is + if next_char(connection, dead_line,dos, s) is { error(msg) then error(msg), ok(c) then if c = '\\' - then if next_char(connection,dead_line,dos) is + then if next_char(connection,dead_line,dos, s) is { error(msg) then error(msg), ok(d) then if d = '\"' - then read_string(connection,dead_line,['\"' . so_far],dos) - else read_string(connection,dead_line,[d, c . so_far],dos) + then read_string(connection,dead_line,['\"' . so_far],dos, s) + else read_string(connection,dead_line,[d, c . so_far],dos, s) } else if c = '\"' then ok(implode(reverse(so_far))) - else read_string(connection,dead_line,[c . so_far],dos) + else read_string(connection,dead_line,[c . so_far],dos, s) }. @@ -1263,31 +1274,32 @@ define Result(Error,One) ( BufferedConnection connection, Int dead_line, - DenialOfService dos + DenialOfService dos, + SState s ) = - if next_char(connection,dead_line,dos) is + if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(c) then if is_strict_blank(c) - then skip_http_blanks(connection,dead_line,dos) + then skip_http_blanks(connection, dead_line, dos, s) else if c = 13 - then if next_char(connection,dead_line,dos) is + then if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), // (unput(c); ok(unique)), ok(d) then if d = 10 - then if next_char(connection,dead_line,dos) is + then if next_char(connection, dead_line, dos, s) 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,dead_line,dos) - else (unput(e); unput(d); unput(c); ok(unique)) + then skip_http_blanks(connection, dead_line, dos, s) + else (unput(e, s); unput(d, s); unput(c, s); ok(unique)) } - else (unput(d); unput(c); ok(unique)) + else (unput(d, s); unput(c, s); ok(unique)) } - else (unput(c); ok(unique)) + else (unput(c, s); ok(unique)) }. @@ -1319,28 +1331,29 @@ define Result(Error,One) ( BufferedConnection connection, Int dead_line, - DenialOfService dos + DenialOfService dos, + SState s ) = - if skip_http_blanks(connection,dead_line,dos) is + if skip_http_blanks(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(_) then - if next_char(connection,dead_line,dos) is + if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(c) then if c = 13 - then if next_char(connection,dead_line,dos) is + then if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(d) then if d = 10 then ok(unique) - else (unput(d); - unput(c); + else (unput(d, s); + unput(c, s); error(end_of_line_expected)) } - else (unput(c); + else (unput(c, s); error(end_of_line_expected)) }}. @@ -1368,17 +1381,18 @@ define Result(Error,String) ( BufferedConnection connection, Int dead_line, - List(Word8) so_far, - DenialOfService dos + List(Word8) so_far, + DenialOfService dos, + SState s ) = - if next_char(connection,dead_line,dos) is + if next_char(connection,dead_line,dos, s) is { error(msg) then error(msg), ok(c) then if is_blank(c) - then (unput(c); + then (unput(c, s); ok(implode(reverse(so_far)))) - else read_word_aux(connection,dead_line,[c . so_far],dos) + else read_word_aux(connection,dead_line,[c . so_far],dos, s) }. define Result(Error,String) @@ -1386,19 +1400,20 @@ define Result(Error,String) ( BufferedConnection connection, Int dead_line, - DenialOfService dos + DenialOfService dos, + SState s ) = - if skip_http_blanks(connection,dead_line,dos) is + if skip_http_blanks(connection,dead_line,dos, s) is { error(msg) then error(msg), ok(_) then - if next_char(connection,dead_line,dos) is + if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(c) then if c = '\"' - then read_string(connection,dead_line,[],dos) - else read_word_aux(connection,dead_line,[c],dos) + then read_string(connection,dead_line,[],dos, s) + else read_word_aux(connection,dead_line,[c],dos, s) } }. @@ -1560,18 +1575,19 @@ define Result(Error,HTTP_RequestLine) ( BufferedConnection connection, Int dead_line, - DenialOfService dos + DenialOfService dos, + SState s ) = - if read_word(connection,dead_line,dos) is + if read_word(connection, dead_line, dos, s) is { error(msg) then error(msg), - ok(get_or_post) then if read_word(connection,dead_line,dos) is + ok(get_or_post) then if read_word(connection, dead_line, dos, s) is { error(msg) then error(msg), - ok(uri_and_query_string) then if read_word(connection,dead_line,dos) is + ok(uri_and_query_string) then if read_word(connection, dead_line, dos, s) is { error(msg) then error(msg), - ok(http_version) then if read_new_line(connection,dead_line,dos) is + ok(http_version) then if read_new_line(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(_) then if separate_uri_from_query_string(uri_and_query_string,0) is @@ -1616,16 +1632,17 @@ define Result(Error,String) ( BufferedConnection connection, Int dead_line, - List(Word8) so_far, - DenialOfService dos + List(Word8) so_far, + DenialOfService dos, + SState s ) = - if next_char(connection,dead_line,dos) is + if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(c) then if is_header_name_char(c) - then read_header_name(connection,dead_line,[to_lower(c) . so_far],dos) - else unput(c); ok(implode(reverse(so_far))) + then read_header_name(connection,dead_line,[to_lower(c) . so_far],dos, s) + else unput(c, s); ok(implode(reverse(so_far))) }. define Result(Error,One) @@ -1633,13 +1650,14 @@ define Result(Error,One) ( BufferedConnection connection, Int dead_line, - DenialOfService dos + DenialOfService dos, + SState s ) = - if skip_http_blanks(connection,dead_line,dos) is + if skip_http_blanks(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(_) then - if next_char(connection,dead_line,dos) is + if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(c) then @@ -1654,30 +1672,31 @@ define Result(Error,String) ( BufferedConnection connection, Int dead_line, - List(Word8) so_far, - DenialOfService dos + List(Word8) so_far, + DenialOfService dos, + SState s ) = - if next_char(connection,dead_line,dos) is + if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(c) then if c = 13 - then if next_char(connection,dead_line,dos) is + then if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(d) then if d = 10 - then if next_char(connection,dead_line,dos) is + then if next_char(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(e) then if is_strict_blank(e) - then read_header_value(connection,dead_line,[e . so_far],dos) - else (unput(e); ok(implode(reverse(so_far)))) + then read_header_value(connection,dead_line, [e . so_far], dos, s) + else (unput(e, s); ok(implode(reverse(so_far)))) } - else read_header_value(connection,dead_line,[d, c . so_far],dos) + else read_header_value(connection,dead_line,[d, c . so_far],dos, s) } - else read_header_value(connection,dead_line,[c . so_far],dos) + else read_header_value(connection,dead_line,[c . so_far],dos, s) }. @@ -1688,26 +1707,27 @@ define Result(Error,Maybe(HTTP_header)) ( BufferedConnection connection, Int dead_line, - DenialOfService dos + DenialOfService dos, + SState s ) = - if read_header_name(connection,dead_line,[],dos) is + if read_header_name(connection, dead_line, [], dos, s) is { error(msg) then error(msg), ok(name) then if name = "" then - if read_and_ignore(connection,dead_line,2,dos) /* 13 and 10 */ is + if read_and_ignore(connection, dead_line, 2, dos, s) /* 13 and 10 */ is { error(msg) then error(msg), ok(_) then // this is the blank line ok(failure) // end of headers } - else if skip_colon(connection,dead_line,dos) is + else if skip_colon(connection, dead_line, dos, s) is { error(msg) then error(msg), - ok(_) then if skip_http_blanks(connection,dead_line,dos) is + ok(_) then if skip_http_blanks(connection, dead_line, dos, s) is { error(msg) then error(msg), - ok(_) then if read_header_value(connection,dead_line,[],dos) is + ok(_) then if read_header_value(connection, dead_line, [], dos, s) is { error(msg) then error(msg), ok(value) then @@ -1726,16 +1746,17 @@ define Result(Error,List(HTTP_header)) ( BufferedConnection connection, Int dead_line, - DenialOfService dos + DenialOfService dos, + SState s ) = - if read_header(connection,dead_line,dos) is + if read_header(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(mbh) then if mbh is { failure then ok([ ]), success(header) then - if read_http_headers(connection,dead_line,dos) is + if read_http_headers(connection, dead_line, dos, s) is { error(msg) then error(msg), ok(others) then ok([header . others]) @@ -2169,7 +2190,7 @@ define Bool ) = if input_etag is { - failure then false, + failure then false, success(etag) then trim_token(etag, '\"') = current_etag //remove triming " because this is quoted string }. @@ -2197,7 +2218,7 @@ define One { false then forget(reliable_write(connection,to_byte_array("HTTP/1.1 200 OK"+crlf))); - forget(reliable_write(connection,[format_headers(headers + headers_for_send_file(mime_type, size, "\""+current_etag+"\"", mb_ftimes)) , crlf])); + forget(reliable_write(connection,[format_headers(headers + headers_for_send_file(mime_type, size, current_etag, mb_ftimes)) , crlf])); //forget(copy_file_to_Connection(file, connection, size)), send_file_body(desc,connection,file,size,0,filename), true then @@ -2253,8 +2274,8 @@ define One failure then println("HTTP/1.1 404 Not Found"+path); forget(reliable_write(connection,to_byte_array("HTTP/1.1 404 Not Found"+crlf+ - "Content-Length: 0"+crlf+ - "Connection: close"+crlf+crlf))); + "Content-Length: 0"+crlf+crlf + /*+"Connection: close"+crlf+crlf*/))); log_journal_msg(desc,"Cannot find file '"+path+"'.\n"), success(f) then with size = file_size(f), send_file(desc, @@ -2283,8 +2304,8 @@ define One failure then println("HTTP/1.1 404 Not Found"+absolute_path); forget(reliable_write(connection,to_byte_array("HTTP/1.1 404 Not Found"+crlf+ - "Content-Length: 0"+crlf+ - "Connection: close"+crlf+crlf))); + "Content-Length: 0"+crlf+crlf + /*+"Connection: close"+crlf+crlf*/))); log_journal_msg(desc,"Cannot find file '"+absolute_path+"'.\n"), success(f) then with size = file_size(f), mime_type = if recognize_mime_type_from_uri(desc,uri) is @@ -2324,7 +2345,7 @@ public define List(HTTP_header) [ http_header("Date", format_http_date(now)), http_header("Server", "Anubis Embedded Server v" + major_version_number + "." + minor_version_number), - http_header("Connection", "close"), + /*http_header("Connection", "close"), */ ]. public define List(HTTP_header) @@ -2642,7 +2663,7 @@ define Maybe((String,Maybe(String))) *** [5.7.3] Creating a temporary filename for an uploaded file. -variable Int uploaded_file_count = 0. + variable Int uploaded_file_count = 0. This variable is local to the virtual machine. Hence, its value is 0 each time a new requests arrives. Temporary uploaded files are stored in the directory represented by @@ -2668,10 +2689,11 @@ define Maybe(String) // returns the temporary file name Web_Site_Description desc, ByteArray body, Int start, - Int end + Int end, + SState s ) = - uploaded_file_count <- 1 + *uploaded_file_count; - with tfn = "_"+to_decimal(virtual_machine_id)+"_"+to_decimal(*uploaded_file_count), + s.uploaded_file_count <- 1 + *(s.uploaded_file_count); + with tfn = "_"+to_decimal(virtual_machine_id)+"_"+to_decimal(*(s.uploaded_file_count)), if (Maybe(RWStream))file(site_directory(desc)+"/upload_temporary/"+tfn, new) is { failure then failure, @@ -2735,7 +2757,8 @@ define Maybe(Web_arg) Web_Site_Description desc, ByteArray body, Int start, - Int end + Int end, + SState s ) = if find(to_byte_array(crlf+crlf),body,start) is { @@ -2754,7 +2777,7 @@ define Maybe(Web_arg) // we must substract 2 to end because of crlf just before the boundary success(fn) then - if save_uploaded_file(desc,body,k+4,end-2) is + if save_uploaded_file(desc, body, k+4, end-2, s) is { failure then failure, success(tfn) then @@ -2775,6 +2798,7 @@ define List(Web_arg) ByteArray body, ByteArray __boundary, Int i, + SState s ) = if find(__boundary,body,i) is { @@ -2784,11 +2808,11 @@ define List(Web_arg) { failure then [ ], success(m) then - if get_multipart_entity(desc,body,n+length(__boundary),m) is + if get_multipart_entity(desc, body, n+length(__boundary), m, s) is { failure then [ ], success(wa) then - [wa . read_multipart_form_data_encoded_web_args(desc,body,__boundary,m)] + [wa . read_multipart_form_data_encoded_web_args(desc, body, __boundary, m, s)] } } }. @@ -2801,11 +2825,12 @@ define One String host_name, Web_Site_Description desc, Connection connection, - Word32 ip_addr, + Word32 ip_addr, HTTP_RequestLine request_line, List(HTTP_header) headers, ByteArray body, - One -> String generate_tt + One -> String generate_tt, + SState s ) = if get_boundary(headers) is { @@ -2815,7 +2840,8 @@ define One read_multipart_form_data_encoded_web_args(desc, body, to_byte_array("--"+boundary), - 0), + 0, + s), uri = uri(request_line), ext = get_uri_extension(uri), log_journal_msg(desc, @@ -2958,7 +2984,8 @@ define One HTTP_RequestLine rqline, List(HTTP_header) headers, ByteArray body, - One -> String generate_tt + One -> String generate_tt, + SState s ) = if rqline is request_line(type,uri,qstring) then with rqline2 = request_line(type,handle_redirection(redirections(desc),uri,headers),qstring), @@ -2968,7 +2995,7 @@ define One www_url then www_url_answer(host_name,desc,connection,ip_addr,rqline2,headers,body,generate_tt), multipart_form_data then - multipart_form_data_answer(host_name,desc,connection,ip_addr,rqline2,headers,body,generate_tt) + multipart_form_data_answer(host_name,desc,connection,ip_addr,rqline2,headers,body,generate_tt, s) }. @@ -3068,20 +3095,21 @@ define One List(Web_Site_Description) sites, BufferedConnection connection, Bool is_https, - DenialOfService dos + DenialOfService dos, + SState s ) = //t0 <- (UTime)unow; with start_time = (Int)now, - sttm <- start_time; + s.sttm <- start_time; //println("Request time: " + format_http_date(start_time)); if dos is denial_of_service(mc_v,rld_v,hd_v,ad_v,ld_v,ra_v) then if remote_IP_address_and_port(connection.conn) is (ip_addr,port) then - if read_request_line(connection,start_time+*rld_v,dos) is + if read_request_line(connection, start_time+*rld_v, dos, s) is { error(msg) then print(format(msg)), ok(request_line) then //print_delta("read_request_line"); - if read_http_headers(connection,start_time+*hd_v,dos) is + if read_http_headers(connection, start_time+*hd_v, dos, s) is { error(msg) then print(format(msg)), ok(headers) then //print_delta("read_http_headers"); @@ -3101,7 +3129,9 @@ define One ok(body) then //print_delta("before send_answer"); send_answer(host_name, desc,connection.conn, request_line, headers, body, - make_generate_trust_ticket(dos)) + make_generate_trust_ticket(dos), s); + //it's HTTP 1.1 keep-alive is default + http_https_handler(sites, connection, is_https, dos, s) //with duration = (UTime) unow - *t0, //println("Request duration: " + __utime_to_string(duration)) //println("BufferRead duration: " + __utime_to_string(*t1)); @@ -3121,8 +3151,8 @@ define Bool is_dubious_IP(Word32 ip, DenialOfService dos). define Server -> ((RWStream) -> One) make_http_handler ( - List(Web_Site_Description) sites, - DenialOfService dos + List(Web_Site_Description) sites, + DenialOfService dos ) = (Server server) |-> (RWStream conn) |-> if remote_IP_address_and_port(conn) is (addr,_) then @@ -3130,8 +3160,7 @@ define Server -> ((RWStream) -> One) 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)), - http_https_handler(sites, connection, false, dos). - + http_https_handler(sites, connection, false, dos, sstate(var([]),var(0),var(0))). public define One http_direct_handler ( @@ -3144,18 +3173,18 @@ public define One 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)), - http_https_handler(sites, connection, false, dos). + http_https_handler(sites, connection, false, dos, sstate(var([]),var(0),var(0))). define Server -> (SSL_Connection -> One) make_https_handler ( - List(Web_Site_Description) sites, - DenialOfService dos + List(Web_Site_Description) sites, + DenialOfService dos ) = (Server server) |-> (SSL_Connection conn) |-> with connection = buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0)), - http_https_handler(sites, connection, true, dos). + http_https_handler(sites, connection, true, dos, sstate(var([]),var(0),var(0))). @@ -3435,12 +3464,12 @@ public define StartServerResult ( Word32 ip_address, Word32 port, - List(Web_Site_Description) sites, - DenialOfService dos + List(Web_Site_Description) sites, + DenialOfService dos ) = create_directories(sites); start_http_server(ip_address,port, - make_http_handler(sites,dos), + make_http_handler(sites, dos), 0, dos). @@ -3480,15 +3509,15 @@ define StartServerResult public define StartServerResult start_https_server ( - Word32 ip_address, - Word32 port, - String certificate_common_name, // of SSL server certificate - List(Web_Site_Description) sites, - DenialOfService dos + Word32 ip_address, + Word32 port, + String certificate_common_name, // of SSL server certificate + List(Web_Site_Description) sites, + DenialOfService dos ) = create_directories(sites); start_https_server(ip_address,port,certificate_common_name, - make_https_handler(sites,dos), + make_https_handler(sites, dos), 0,dos). @@ -3541,16 +3570,17 @@ define Server -> ((RWStream) -> One) make_dispatcher_handler ( Var(List(DispatcherInfo)) info_v, - DenialOfService dos + DenialOfService dos, + SState s ) = (Server server) |-> (RWStream conn) |-> with start_time = (Int)now, connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0)), - if read_request_line(connection, start_time+*request_line_delay(dos), dos) is + if read_request_line(connection, start_time+*request_line_delay(dos), dos, s) is { error(msg) then print(format(msg)), ok(request_line) then - if read_http_headers(connection, start_time+*headers_delay(dos), dos) is + if read_http_headers(connection, start_time+*headers_delay(dos), dos, s) is { error(msg) then print(format(msg)), ok(headers) then if get_host_header_value(headers) is @@ -3627,7 +3657,8 @@ public define One ( Word32 ip_address, // address for listening (typically 0: listen on all interfaces) Word32 http_port, // typically 80 - DenialOfService dos + DenialOfService dos, + SState s ) = with info_file_path = my_anubis_directory+"/web_sites/dispatcher.info", info_v = var((List(DispatcherInfo))[]), @@ -3635,7 +3666,7 @@ public define One if dispatcher_update_data(info_file_path,info_v,info_date_v) then if start_server(ip_address, http_port, - make_dispatcher_handler(info_v,dos), + make_dispatcher_handler(info_v, dos, s), (One u)|->u) is { cannot_create_the_socket then -- libgit2 0.21.4