BUG/MINOR: http-fetch: Fix test on message state to capture the version
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 1 Apr 2021 14:00:29 +0000 (16:00 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 1 Apr 2021 14:45:40 +0000 (16:45 +0200)
A bug was introduced when the legacy HTTP mode was removed. To capture the
HTTP version of the request or the response, we rely on the message state to
be sure the status line was received. However, the test is inverted. The
version can be captured if message headers were received, not the opposite.

This patch must be backported as far as 2.2.

src/http_fetch.c

index a4db061..0d2be7e 100644 (file)
@@ -1525,7 +1525,7 @@ static int smp_fetch_capture_req_ver(const struct arg *args, struct sample *smp,
                return 0;
 
        txn = smp->strm->txn;
-       if (!txn || txn->req.msg_state >= HTTP_MSG_BODY)
+       if (!txn || txn->req.msg_state < HTTP_MSG_BODY)
                return 0;
 
        if (txn->req.flags & HTTP_MSGF_VER_11)
@@ -1551,7 +1551,7 @@ static int smp_fetch_capture_res_ver(const struct arg *args, struct sample *smp,
                return 0;
 
        txn = smp->strm->txn;
-       if (!txn || txn->rsp.msg_state >= HTTP_MSG_BODY)
+       if (!txn || txn->rsp.msg_state < HTTP_MSG_BODY)
                return 0;
 
        if (txn->rsp.flags & HTTP_MSGF_VER_11)