BUG/MINOR: http: make smp_fetch_body() report that the contents may change
authorWilly Tarreau <w@1wt.eu>
Mon, 15 Jun 2020 16:01:10 +0000 (18:01 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 3 Jul 2020 17:03:54 +0000 (19:03 +0200)
The req_body and res_body sample fetch functions forgot to set the
SMP_F_MAY_CHANGE flag, making them unusable in tcp content rules. Now we
set the flag as long as the channel is not full and nothing indicates
the end was reached.

This is marked as a bug because it's unusual for a sample fetch function
to return a final verdict while data my change, but this results from a
limitation that was affecting the legacy mode where it was not possible
to know whether the end was reached without de-chunking the message. In
HTX there is no more reason to limit this. This fix could be backported
to 2.1, and to 2.0 if really needed, though it will only be doable for
HTX, and legacy cannot be fixed.

(cherry picked from commit 9dc92b2650a83a17db9779eadf63cb011be4f8ff)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/http_fetch.c

index 22797e2..2a02b66 100644 (file)
@@ -571,6 +571,10 @@ static int smp_fetch_body(const struct arg *args, struct sample *smp, const char
        smp->data.type = SMP_T_BIN;
        smp->data.u.str = *temp;
        smp->flags = SMP_F_VOL_TEST;
+
+       if (!channel_full(chn, global.tune.maxrewrite) && !(chn->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)))
+               smp->flags |= SMP_F_MAY_CHANGE;
+
        return 1;
 }