MINOR: http-ana: Perform L7 retries because of status codes in response analyser

L7 retries because of status codes are now performed in the response
analyser. This way, it is no longer required to handle L7 retries in
si_cs_recv(). It is also useless to set CF_READ_ERROR on the response
channel to be able to trigger such retries.

In addition, if no L7 retries are performed when the response is received,
the L7 buffer is immediately released. Before in this case, it was only
released with the stream.

(cherry picked from commit 1f08bffe0cfaaedfc3e022c7c3be1580c3ed68de)
[Cf: This one was backported to 2.4 to ease future backports]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/http_ana.c b/src/http_ana.c
index a52b0f2..a045e53 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -1542,10 +1542,23 @@
 	 * response which at least looks like HTTP. We have an indicator
 	 * of each header's length, so we can parse them quickly.
 	 */
-	msg->msg_state = HTTP_MSG_BODY;
 	BUG_ON(htx_get_first_type(htx) != HTX_BLK_RES_SL);
 	sl = http_get_stline(htx);
 
+	/* Perform a L7 retry because of the status code */
+	if ((si_b->flags & SI_FL_L7_RETRY) &&
+	    l7_status_match(s->be, sl->info.res.status) &&
+	    do_l7_retry(s, si_b) == 0) {
+		DBG_TRACE_DEVEL("leaving on L7 retry", STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA, s, txn);
+		return 0;
+	}
+
+	/* Now, L7 buffer is useless, it can be released */
+	b_free(&s->si[1].l7_buffer);
+
+	msg->msg_state = HTTP_MSG_BODY;
+
+
 	/* 0: we might have to print this header in debug mode */
 	if (unlikely((global.mode & MODE_DEBUG) &&
 		     (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 6d26919..cd01840 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -1367,28 +1367,6 @@
 			break;
 		}
 
-		/* L7 retries enabled and maximum connection retries not reached */
-		if ((si->flags & SI_FL_L7_RETRY) && si->conn_retries) {
-			struct htx *htx;
-			struct htx_sl *sl;
-
-			htx = htxbuf(&ic->buf);
-			if (htx) {
-				sl = http_get_stline(htx);
-				if (sl && l7_status_match(si_strm(si)->be,
-				    sl->info.res.status)) {
-					/* If we got a status for which we would
-					 * like to retry the request, empty
-					 * the buffer and pretend there's an
-					 * error on the channel.
-					 */
-					ic->flags |= CF_READ_ERROR;
-					htx_reset(htx);
-					return 1;
-				}
-			}
-			si->flags &= ~SI_FL_L7_RETRY;
-		}
 		cur_read += ret;
 
 		/* if we're allowed to directly forward data, we must update ->o */