From: Christopher Faulet Date: Tue, 17 Nov 2026 14:28:55 +0000 (+0100) Subject: MINOR: tcpcheck: evaluate custom expect rules on empty response when allowed X-Git-Url: https://git.kaiwu.me/http/ngx_http_rewrite_module.html?a=commitdiff_plain;h=c57a1d92aa48eb708e13f78fbb62aa8de837c992;p=haproxy.git MINOR: tcpcheck: evaluate custom expect rules on empty response when allowed 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. --- diff --git a/src/tcpcheck.c b/src/tcpcheck.c index 99993a7a1..036a46998 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -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);