From 2520054b152863babbc01cd5d7bab5d5f7705667 Mon Sep 17 00:00:00 2001 From: dormando Date: Mon, 1 Aug 2022 11:19:14 -0700 Subject: proxy: add r:has_flag(), fix r:token() length Add mcp.request function for quick checking if a flag exists in a request string. Also updates internal code for checking the length of a token to use the endcap properly, and uses that for the r:token(n) requets as well, which fixes a subtle bug of the token length being too long. --- t/startfile.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't') diff --git a/t/startfile.lua b/t/startfile.lua index c204d49..6abaa75 100644 --- a/t/startfile.lua +++ b/t/startfile.lua @@ -159,6 +159,19 @@ function failover_factory(zones, local_zone) end end +function meta_get_factory(zones, local_zone) + local near_zone = zones[local_zone] + -- in this test function we only fetch from the local zone. + return function(r) + if r:has_flag("l") == true then + print("client asking for last access time") + end + local res = near_zone(r) + + return res + end +end + -- SET's to main zone, issues deletes to far zones. function setinvalidate_factory(zones, local_zone) local near_zone = zones[local_zone] @@ -288,6 +301,7 @@ function mcp_config_routes(main_zones) -- need better routes designed for the test suite (edit the key -- prefix or something) map[mcp.CMD_ADD] = failover_factory(z, my_zone) + map[mcp.CMD_MG] = meta_get_factory(z, my_zone) prefixes[pfx] = command_factory(map, failover) end -- cgit v1.2.1