Skip to content

Commit

Permalink
Added expiration_function to http options map
Browse files Browse the repository at this point in the history
  • Loading branch information
VOS Maintainer committed Jun 5, 2012
1 parent e6ff80b commit 83f0264
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libsrc/Wi/http.c
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions libsrc/Wi/http.h
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion libsrc/Wi/url_rewrite.sql
Expand Up @@ -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);
Expand All @@ -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))
{
Expand All @@ -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;

Expand Down

0 comments on commit 83f0264

Please sign in to comment.