From: Christopher Faulet Date: Wed, 4 Jan 2023 09:11:32 +0000 (+0100) Subject: BUG/MINOR: http-fetch: Only fill txn status during prefetch if not already set X-Git-Tag: v2.8-dev1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31850b470a9c59d04349174df6b51de1efe41420;p=thirdparty%2Fhaproxy.git BUG/MINOR: http-fetch: Only fill txn status during prefetch if not already set 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. --- diff --git a/src/http_fetch.c b/src/http_fetch.c index abb19a4554..b5e4f36171 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -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;