]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tcpcheck: Only wait for more payload data on HTTP expect rules
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 9 Dec 2020 17:45:47 +0000 (18:45 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 11 Dec 2020 10:48:15 +0000 (11:48 +0100)
For HTTP expect rules, if the buffer is not empty, it is guarantee that all
responses headers are received, with the start-line. Thus, except for
payload matching, there is no reason to wait for more data from the moment
the htx message is not empty.

This patch may be backported as far as 2.2.

src/tcpcheck.c

index 15d4a25291467606be8e43c1723393acb20d01e8..9d3b411e518b3e494899c8c270b11d1b046fa151 100644 (file)
@@ -1754,6 +1754,14 @@ enum tcpcheck_eval_ret tcpcheck_eval_expect_http(struct check *check, struct tcp
                else
                        match = regex_exec2(expect->regex, b_orig(&trash), b_data(&trash));
 
+               /* Wait for more data on mismatch only if no minimum is defined (-1),
+                * otherwise the absence of match is already conclusive.
+                */
+               if (!match && !last_read && (expect->min_recv == -1)) {
+                       ret = TCPCHK_EVAL_WAIT;
+                       goto out;
+               }
+
                /* Set status and description in case of error */
                status = ((status != HCHK_STATUS_UNKNOWN) ? status : HCHK_STATUS_L7RSP);
                if (LIST_ISEMPTY(&expect->onerror_fmt))
@@ -1769,14 +1777,6 @@ enum tcpcheck_eval_ret tcpcheck_eval_expect_http(struct check *check, struct tcp
                goto error;
        }
 
-       /* Wait for more data on mismatch only if no minimum is defined (-1),
-        * otherwise the absence of match is already conclusive.
-        */
-       if (!match && !last_read && (expect->min_recv == -1)) {
-               ret = TCPCHK_EVAL_WAIT;
-               goto out;
-       }
-
        if (!(match ^ inverse))
                goto error;