BUG/MINOR: http-ana: make set-status also update txn->status

Patrick Hemmer reported an interesting case where the status present in
the logs doesn't reflect what was reported to the user. During analysis
we could figure that it was in fact solely caused by the code dealing
with the set-status action. Indeed, set-status does update the status
in the HTX message itself but not in the HTTP transaction. However, at
most places where the status is needed to take a decision, it is
retrieved from the transaction, and the logs proceed like this as well,
though the "status" sample fetch function does retrieve it from the HTX
data. This particularly means that once a set-status has been used to
modify the status returned to the user, logs do not match that status,
and the response code distribution doesn't match either. However a
subsequent rule using the status as a condition will still match because
the "status" sample fetch function does also extract the status from the
HTX stream. Here's an example that fails:

  frontend f
    bind :8001
    mode http
    option httplog
    log stdout daemon
    http-after-response set-status 400

This will return a 400 to the client but log a 503 and increment
http_rsp_5xx.

In the end the root cause is that we need to make txn->status the only
authoritative place to get the status, and as such it must be updated
by the set-status rule. Ideally "status" should just use txn->status
but with the two synchronized this way it's not needed.

This should be backported since it addresses some consistency issues
between logs and what's observed. The set-status action appeared in
1.9 so all stable versions are eligible.

(cherry picked from commit 640e253698b1016f115552d1d5bbb81e5263377d)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 87c1d795d7e9299d374a7ef9c6beda5e3bbea354)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit b2817a3bdc6eec1a6cef1a32a14df20637ecf536)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 0feac3375eaf7a651497ba2570877d4db83f834e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
1 file changed