Skip to content

Commit 8c1b741

Browse files
committed
in plugins allow 'null' name to clear txn strategy
1 parent ac5a3b2 commit 8c1b741

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

doc/admin-guide/plugins/header_rewrite.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ set-next-hop-strategy
10931093
Replaces/Sets the current next hop parent selection strategy with
10941094
the matching strategy specified in `strategies.yaml`
10951095

1096-
Setting to "" removes the current strategy which will fall back
1096+
Setting to "null" removes the current strategy which will fall back
10971097
to other methods (ie: parent.config or remap to url).
10981098

10991099
set-redirect

doc/admin-guide/plugins/lua.en.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,8 +1958,8 @@ ts.http.set_next_hop_strategy
19581958
**description** Looks for the named strategy and sets the current
19591959
transaction to use that strategy.
19601960

1961-
Use empty string to clear the strategy and fall back to parent.config
1962-
or the remap to url.
1961+
Use empty string or "null" to clear the strategy and fall back to
1962+
parent.config or the remap to url.
19631963

19641964
Here is an example:
19651965

doc/admin-guide/plugins/regex_remap.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ remap.config. The following options are available ::
143143

144144
@caseless - Make regular expressions case insensitive
145145
@lowercase_substitutions - Turn on (enable) lower case substitutions
146-
@strategy - Specify a strategy from strategies.yaml
146+
@strategy - Specify a strategy from strategies.yaml. "null" or "" will clear the strategy.
147147

148148

149149
This can be useful to force a particular response for some URLs, e.g. ::

plugins/header_rewrite/operators.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ OperatorSetNextHopStrategy::exec(const Resources &res) const
16581658
_value.append_value(value, res);
16591659

16601660
// Setting an empty strategy clears it for either parent.config or remap to
1661-
if (value.empty()) {
1661+
if ("null" == value || value.empty()) {
16621662
Dbg(pi_dbg_ctl, "Clearing strategy");
16631663
TSHttpTxnNextHopStrategySet(txnp, nullptr);
16641664
return true;

plugins/lua/ts_lua_http.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ ts_lua_http_set_next_hop_strategy(lua_State *L)
565565
size_t name_len;
566566

567567
name = luaL_checklstring(L, 1, &name_len);
568-
if (0 == name_len) {
568+
if (0 == name_len || "null" == std::string_view(name)) {
569569
Dbg(dbg_ctl, "Clearning strategy (use parent.config)");
570570
TSHttpTxnNextHopStrategySet(http_ctx->txnp, nullptr);
571571
} else {

plugins/regex_remap/regex_remap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
981981
TSHttpTxnDNSTimeoutSet(txnp, re->dns_timeout_option());
982982
}
983983
auto const &strat = re->strategy();
984-
if (strat.empty()) {
984+
if (strat.empty() || "null" == strat) {
985985
Dbg(dbg_ctl, "Clearing strategy (use parent.config)");
986986
TSHttpTxnNextHopStrategySet(txnp, nullptr);
987987
} else {

tests/gold_tests/pluginTest/strategies/strategies_plugins.test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
'/nh1 http://origin/path @strategy=',
107107
"/nh2 http://origin/path @strategy=nh0",
108108
])
109-
ts.Disk.MakeConfigFile("strat.lua").AddLines(
109+
ts.Disk.MakeConfigFile("strategies.lua").AddLines(
110110
[
111111
'function do_remap()',
112112
' local uri = ts.client_request.get_uri()',
@@ -168,9 +168,9 @@
168168
"map http://nh0_rr http://origin @strategy=nh0 @plugin=regex_remap.so @pparam=regex_remap.config",
169169
"map http://nh1_rr http://origin @strategy=nh1 @plugin=regex_remap.so @pparam=regex_remap.config",
170170
"map http://nh2_rr http://origin @plugin=regex_remap.so @pparam=regex_remap.config",
171-
"map http://nh0_lua http://origin @strategy=nh0 @plugin=tslua.so @pparam=strat.lua",
172-
"map http://nh1_lua http://origin @strategy=nh1 @plugin=tslua.so @pparam=strat.lua",
173-
"map http://nh2_lua http://origin @plugin=tslua.so @pparam=strat.lua",
171+
"map http://nh0_lua http://origin @strategy=nh0 @plugin=tslua.so @pparam=strategies.lua",
172+
"map http://nh1_lua http://origin @strategy=nh1 @plugin=tslua.so @pparam=strategies.lua",
173+
"map http://nh2_lua http://origin @plugin=tslua.so @pparam=strategies.lua",
174174
])
175175

176176
# Tests

0 commit comments

Comments
 (0)