MINOR: tcpcheck: Only wait for more payload data on HTTP expect rules

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.

(cherry picked from commit cad5f5e1ede350e92a0e0b1626d636f1c70c646d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index eed935c..63ac4ff 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -1758,6 +1758,14 @@
 		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))
@@ -1773,14 +1781,6 @@
 		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;