]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: http-ana: return a 502 when checkcache blocks a response
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 09:03:34 +0000 (11:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 14:11:24 +0000 (16:11 +0200)
The documentation of "option checkcache" states that a response which
does not respect its requirements "will be blocked just as if it was
from an http-response deny rule, with an HTTP 502 bad gateway".

The code jumps to the "deny" label without touching txn->status, which
at that point still holds the status the server had returned. The
response delivered to the client is thus a 200 (or anything else that
the server returned), and the error files are not even used in this
case. Let's just properly set the status to 502 just like the other
rules such as "http-response deny" do. It now does what the doc says.

This has been there forever so it can be backported to all stable
branches.

src/http_ana.c

index c3f5786f6458b4dcf3308c63fd87b867239a03d8..bf24821783b062f7012d34dfd681ae197b24fa08 100644 (file)
@@ -1996,6 +1996,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
                send_log(s->be, LOG_ALERT,
                         "Blocking cacheable cookie in response from instance %s, server %s.\n",
                         s->be->id, objt_server(s->target) ? __objt_server(s->target)->id : "<dispatch>");
+               txn->status = 502;
                goto deny;
        }