]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http-fetch: Only fill txn status during prefetch if not already set
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 4 Jan 2023 09:11:32 +0000 (10:11 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Jan 2023 08:33:23 +0000 (09:33 +0100)
When an HTTP sample fetch is evaluated, a prefetch is performed to check the
channel contains a valid HTTP message. If the HTTP analysis was not already
started, some info are filled.

It may be an issue when an error is returned before the response analysis
and when http-after-response rules are used because the original HTTP txn
status may be crushed. For instance, with the following configuration:

  listen l1
    log global
    mode http
    bind :8000

    log-format ST=%ST
    http-after-response set-status 400
    #http-after-response set-var(res.foo) status

A "ST=503" is reported in the log messages, independantly on the first
http-after-response rule. The same must happen if the second rule is
uncommented. However, for now, a "ST=400" is logged.

To fix the bug, during the prefetch, the HTTP txn status is only set if it
is undefined (-1). This way, we are sure the original one is never lost.

This patch should be backported as far as 2.2.

src/http_fetch.c

index abb19a4554533549dd87601db963642385c8ca0d..b5e4f3617189995169d354c5712e512a31eea637 100644 (file)
@@ -311,7 +311,7 @@ struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, struct che
                        if (txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD)
                                s->flags |= SF_REDIRECTABLE;
                }
-               else
+               else if (txn->status == -1)
                        txn->status = sl->info.res.status;
                if (sl->flags & HTX_SL_F_VER_11)
                        msg->flags |= HTTP_MSGF_VER_11;