]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http-rules: Add missing actions in http-after-response ruleset
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Jan 2023 10:17:38 +0000 (11:17 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Jan 2023 10:23:59 +0000 (11:23 +0100)
This patch adds the support of following actions in the http-after-response
ruleset:

  * set-map, del-map and del-acl
  * set-log-level
  * sc-inc-gpc, sc-inc-gpc0 and set-inc-gpc1
  * sc-inc-gpt and sc-set-gpt0

This patch should solve the issue #1980.

doc/configuration.txt
src/http_act.c
src/stick_table.c
src/stream.c

index 9ab84abecb6001d66214f9fce3df018b6b57d318..8b2b9a6f71bbb3ef06dfb748778abef2f36fe182 100644 (file)
@@ -5811,10 +5811,19 @@ http-after-response <action> <options...> [ { if | unless } <condition> ]
     - add-header <name> <fmt>
     - allow
     - capture <sample> id <id>
+    - del-acl(<file-name>) <key fmt>
     - del-header <name> [ -m <meth> ]
+    - del-map(<file-name>) <key fmt>
     - replace-header <name> <regex-match> <replace-fmt>
     - replace-value <name> <regex-match> <replace-fmt>
+    - sc-inc-gpc(<idx>,<sc-id>)
+    - sc-inc-gpc0(<sc-id>)
+    - sc-inc-gpc1(<sc-id>)
+    - sc-set-gpt(<idx>,<sc-id>) { <int> | <expr> }
+    - sc-set-gpt0(<sc-id>) { <int> | <expr> }
     - set-header <name> <fmt>
+    - set-log-level <level>
+    - set-map(<file-name>) <key fmt> <value fmt>
     - set-status <status> [reason <str>]
     - set-var(<var-name>[,<cond> ...]) <expr>
     - set-var-fmt(<var-name>[,<cond> ...]) <fmt>
@@ -5859,11 +5868,21 @@ http-after-response capture <sample> id <id> [ { if | unless } <condition> ]
   converts it to a string. Please refer to "http-response capture" for a
   complete description.
 
+http-after-response del-acl(<file-name>) <key fmt> [ { if | unless } <condition> ]
+
+  This is used to delete an entry from an ACL. Please refer to "http-request
+  del-acl" for a complete description.
+
 http-after-response del-header <name> [ -m <meth> ] [ { if | unless } <condition> ]
 
   This removes all HTTP header fields whose name is specified in <name>. Please
   refer to "http-request del-header" for a complete description.
 
+http-after-response del-map(<file-name>) <key fmt> [ { if | unless } <condition> ]
+
+  This is used to delete an entry from a MAP. Please refer to "http-request
+  del-map" for a complete description.
+
 http-after-response replace-header <name> <regex-match> <replace-fmt>
                                    [ { if | unless } <condition> ]
 
@@ -5894,6 +5913,34 @@ http-after-response replace-value <name> <regex-match> <replace-fmt>
     # outputs:
     Cache-Control: max-age=3600, private
 
+http-after-response sc-inc-gpc(<idx>,<sc-id>) [ { if | unless } <condition> ]
+http-after-response sc-inc-gpc0(<sc-id>) [ { if | unless } <condition> ]
+http-after-response sc-inc-gpc1(<sc-id>) [ { if | unless } <condition> ]
+
+  These actions increment the General Purppose Counters according to the sticky
+  counter designated by <sc-id>. Please refer to "http-request sc-inc-gpc",
+  "http-request sc-inc-gpc0" and "http-request sc-inc-gpc1" for a complete
+  description.
+
+http-after-response sc-set-gpt(<idx>,<sc-id>) { <int> | <expr> }
+                                              [ { if | unless } <condition> ]
+http-after-response sc-set-gpt0(<sc-id>) { <int> | <expr> }
+                                         [ { if | unless } <condition> ]
+
+  These actions set the 32-bit unsigned General Purpose Tags according to the
+  sticky counter designated by <sc-id>. Please refer to "http-request
+  sc-inc-gpt" and "http-request sc-inc-gpt0" for a complete description.
+
+http-after-response set-log-level <level> [ { if | unless } <condition> ]
+
+  This is used to change the log level of the current response. Please refer to
+  "http-request set-log-level" for a complete description.
+
+http-after-response set-map(<file-name>) <key fmt> <value fmt>
+
+  This is used to add a new entry into a MAP. Please refer to "http-request
+  set-map" for a complete description.
+
 http-after-response set-header <name> <fmt> [ { if | unless } <condition> ]
 
   This does the same as "http-after-response add-header" except that the header
index d4da43983cc899d8a732004ab420a96b840abd8d..5582085d48bc6944f6c17a8d429236fac83480e5 100644 (file)
@@ -2476,10 +2476,13 @@ static struct action_kw_list http_after_res_actions = {
                { "add-header",      parse_http_set_header,     0 },
                { "allow",           parse_http_allow,          0 },
                { "capture",         parse_http_res_capture,    0 },
+               { "del-acl",          parse_http_set_map,       KWF_MATCH_PREFIX },
                { "del-header",      parse_http_del_header,     0 },
+               { "del-map",          parse_http_set_map,       KWF_MATCH_PREFIX },
                { "replace-header",  parse_http_replace_header, 0 },
                { "replace-value",   parse_http_replace_header, 0 },
                { "set-header",      parse_http_set_header,     0 },
+               { "set-map",         parse_http_set_map,        KWF_MATCH_PREFIX },
                { "set-status",      parse_http_set_status,     0 },
                { "strict-mode",     parse_http_strict_mode,    0 },
                { NULL, NULL }
index 507bd094a21b43f88d695a2bd16f0a70ab6ee55e..3533ec09e4da59c1f5d6f51c0a6c05ed564ddd84 100644 (file)
@@ -5077,6 +5077,17 @@ static struct action_kw_list http_res_kws = { { }, {
 
 INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_kws);
 
+static struct action_kw_list http_after_res_kws = { { }, {
+       { "sc-inc-gpc",  parse_inc_gpc,  KWF_MATCH_PREFIX },
+       { "sc-inc-gpc0", parse_inc_gpc,  KWF_MATCH_PREFIX },
+       { "sc-inc-gpc1", parse_inc_gpc,  KWF_MATCH_PREFIX },
+       { "sc-set-gpt",  parse_set_gpt,  KWF_MATCH_PREFIX },
+       { "sc-set-gpt0", parse_set_gpt,  KWF_MATCH_PREFIX },
+       { /* END */ }
+}};
+
+INITCALL1(STG_REGISTER, http_after_res_keywords_register, &http_after_res_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
  */
index 9906b214150cd80814e9379973bdf46cfe117e0d..006c22964d109d55d0b0eb1a81928d685bb3edff 100644 (file)
@@ -3942,6 +3942,13 @@ static struct action_kw_list stream_http_res_keywords = { ILH, {
 
 INITCALL1(STG_REGISTER, http_res_keywords_register, &stream_http_res_keywords);
 
+static struct action_kw_list stream_http_after_res_actions =  { ILH, {
+       { "set-log-level", stream_parse_set_log_level },
+       { /* END */ }
+}};
+
+INITCALL1(STG_REGISTER, http_after_res_keywords_register, &stream_http_after_res_actions);
+
 static int smp_fetch_cur_server_timeout(const struct arg *args, struct sample *smp, const char *km, void *private)
 {
        smp->flags = SMP_F_VOL_TXN;