]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: tcpcheck: evaluate custom expect rules on empty response when allowed
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 17 Nov 2026 14:28:55 +0000 (15:28 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Nov 2026 13:50:40 +0000 (14:50 +0100)
The custom expect functions are not evaluated when the response
buffer is empty. When the TCPCHK_EXPT_FL_ALLOW_EMPTY flag is set
on the rule, the function is now called with an empty buffer, on
the condition it properly handles this situation. It is useful
when the connection closure by the server is itself a valid
result.

src/tcpcheck.c

index 99993a7a103252f5b89959abfd658bd00894841d..036a46998bb9b637332f67eb2bc7033ce42ea3b8 100644 (file)
@@ -2443,12 +2443,11 @@ enum tcpcheck_eval_ret tcpcheck_eval_expect(struct check *check, struct tcpcheck
                break;
 
        case TCPCHK_EXPECT_CUSTOM:
-               /* Don't eval custom function if the buffer is empty. It means
-                * custom functions can't expect an empty response. If this
-                * change, don't forget to change this test and update all
-                * custom functions.
+               /* Don't eval custom function if the buffer is empty, unless
+                * explicitly allowed. Custom functions not flagged as such
+                * can't expect an empty response.
                 */
-               if (!b_data(&check->bi))
+               if (!b_data(&check->bi) && !(expect->flags & TCPCHK_EXPT_FL_ALLOW_EMPTY))
                        break;
                if (expect->custom)
                        ret = expect->custom(check, rule, last_read);