BUG/MINOR: http-fetch: Don't set the sample type during the htx prefetch

A subtle bug was introduced by the commit a6d9879e6 ("BUG/MEDIUM: htx:
smp_prefetch_htx() must always validate the direction"), for the "method"
sample fetch only. The sample data type and the method id are always
overwritten because smp_prefetch_htx() function is called later in the
sample fetch evaluation. The bug is in the smp_prefetch_htx() function but
it is only visible for the "method" sample fetch, for an unknown method.

In fact, when smp_prefetch_htx() is called, the sample object is
altered. The data type is set to SMP_T_BOOL and, on success, the data value
is set to 1.  Thus, if the caller has already set some infos into the sample
object, they may be lost. AFAIK, there is no reason to do so. It is
inherited from the legacy HTTP code and I honestely don't known why it was
done this way. So, instead of fixing the "method" sample fetch to set useful
info after the call to smp_prefetch_htx() function, I prefer to not alter
the sample object in smp_prefetch_htx().

This patch must be backported as far as 2.0. On the 2.0, only the HTX part
must be fixed.
This commit is contained in:
Christopher Faulet 2020-09-18 10:19:02 +02:00
parent 3ca2365904
commit d2414a23c4

View File

@ -217,7 +217,6 @@ struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, struct che
} }
txn = s->txn; txn = s->txn;
msg = (!(chn->flags & CF_ISRESP) ? &txn->req : &txn->rsp); msg = (!(chn->flags & CF_ISRESP) ? &txn->req : &txn->rsp);
smp->data.type = SMP_T_BOOL;
if (IS_HTX_STRM(s)) { if (IS_HTX_STRM(s)) {
htx = htxbuf(&chn->buf); htx = htxbuf(&chn->buf);
@ -315,7 +314,6 @@ struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, struct che
/* everything's OK */ /* everything's OK */
end: end:
smp->data.u.sint = 1;
return htx; return htx;
} }