diff --git a/libsrc/Wi/http.c b/libsrc/Wi/http.c index 802032ee56..b2ee9dac75 100644 --- a/libsrc/Wi/http.c +++ b/libsrc/Wi/http.c @@ -8118,6 +8118,8 @@ bif_http_map_table (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args) } map->hm_cors = ht; } + else if (DV_STRINGP (opts[i]) && !stricmp (opts[i],"expiration_function")) + map->hm_expiration_fn = box_copy_tree (opts[i+1]); } map->hm_opts = (caddr_t *) box_copy_tree ((box_t) opts); } @@ -8931,6 +8933,8 @@ bif_http_map_get (caddr_t *qst, caddr_t * err_ret, state_slot_t **args) res = box_num (map->hm_url_rewrite_keep_lpath); else if (!strcmp (member, "noinherit")) res = box_num (map->hm_no_inherit); + else if (!strcmp (member, "expiration_function")) + res = box_copy_tree ((box_t) map->hm_expiration_fn); return res; } diff --git a/libsrc/Wi/http.h b/libsrc/Wi/http.h index 68eb6e31b5..a281dc37c5 100644 --- a/libsrc/Wi/http.h +++ b/libsrc/Wi/http.h @@ -80,6 +80,7 @@ typedef struct ws_http_map_s int hm_url_rewrite_keep_lpath; id_hash_t * hm_cors; int hm_cors_restricted; + caddr_t hm_expiration_fn; } ws_http_map_t; #endif diff --git a/libsrc/Wi/url_rewrite.sql b/libsrc/Wi/url_rewrite.sql index a3b10d06bb..9c6477326e 100644 --- a/libsrc/Wi/url_rewrite.sql +++ b/libsrc/Wi/url_rewrite.sql @@ -1210,7 +1210,7 @@ create procedure DB.DBA.HTTP_URLREWRITE (in path varchar, in rule_list varchar, declare rule_iri, in_path, qstr, meth varchar; declare target_vhost_pkey, hf, accept, http_headers any; declare result, http_redir, http_tcn_code, tcn_rc, keep_lpath int; - declare http_tcn_headers varchar; + declare http_tcn_headers, exp_fn varchar; -- XXX: the path is just path string, no fragment no query no host --hf := rfc1808_parse_uri (path); @@ -1220,12 +1220,14 @@ create procedure DB.DBA.HTTP_URLREWRITE (in path varchar, in rule_list varchar, in_path := '/'; accept := null; qstr := null; + exp_fn := null; keep_lpath := 0; meth := 'GET'; if (is_http_ctx ()) { keep_lpath := http_map_get ('url_rewrite_keep_lpath'); + exp_fn := http_map_get ('expiration_function'); lines := http_request_header (); if (length (lines)) { @@ -1245,6 +1247,12 @@ create procedure DB.DBA.HTTP_URLREWRITE (in path varchar, in rule_list varchar, lines := vector (); } + if (isstring (exp_fn) and (__proc_exists (exp_fn) is not null) and (1 = call (exp_fn) (lines, http_map_get ('options')))) + { + http_body_read (); + return 1; + } + if (length (qstr)) in_path := in_path || '?' || qstr;