]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http-rules: Return an error when custom actions return ACT_RET_ERR
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Dec 2019 08:36:11 +0000 (09:36 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 20 Jan 2020 14:18:45 +0000 (15:18 +0100)
Thanks to the commit "MINOR: actions: Use ACT_RET_CONT code to ignore an error
from a custom action", it is now possible to trigger an error from a custom
action in http rules. Now, when a custom action returns the ACT_RET_ERR code
from an http-request rule, an error 400 is returned. And from an http-response
rule, an error 502 is returned.

Be careful if this patch is backported. The other mentioned patch must be
backported first.

src/http_ana.c

index 047ed813a5b7f9ddae0f9c737db977dd7066c0ae..f5cdd05c2993ef6fb8fb7bbfa3a3c1c3c79edd69 100644 (file)
@@ -3100,6 +3100,8 @@ static enum rule_result http_req_get_intercept_rule(struct proxy *px, struct lis
 
                                switch (rule->action_ptr(rule, px, s->sess, s, act_flags)) {
                                        case ACT_RET_ERR:
+                                               rule_ret = HTTP_RULE_RES_BADREQ;
+                                               goto end;
                                        case ACT_RET_CONT:
                                                break;
                                        case ACT_RET_STOP:
@@ -3493,6 +3495,8 @@ resume_execution:
 
                                switch (rule->action_ptr(rule, px, s->sess, s, act_flags)) {
                                        case ACT_RET_ERR:
+                                               rule_ret = HTTP_RULE_RES_BADREQ;
+                                               goto end;
                                        case ACT_RET_CONT:
                                                break;
                                        case ACT_RET_STOP: