MEDIUM: filters/htx: Don't rely on HTX extra field if payload is filtered

If an HTTP data filter is registered on a channel, we must not rely on the
HTX extra field because the payload may be changed and we cannot predict if
this value will change or not. It is too errorprone to let filters deal with
this reponsibility. So we set it to 0 when payload filtering is performed,
but only if the payload length can be determined. It is important because
this field may be used when data are forwarded. In fact, it will be used by
the H1 multiplexer to be able to splice chunk-encoded payload.
This commit is contained in:
Christopher Faulet 2023-06-20 13:34:46 +02:00
parent 05fe76b540
commit 8bd835b2d2
1 changed files with 4 additions and 0 deletions

View File

@ -655,6 +655,7 @@ int
flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len)
{
struct filter *filter;
struct htx *htx;
unsigned long long *strm_off = &FLT_STRM_OFF(s, msg->chn);
unsigned int out = co_data(msg->chn);
int ret, data;
@ -702,6 +703,9 @@ flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len)
ret = data;
*strm_off += ret;
end:
htx = htxbuf(&msg->chn->buf);
if (msg->flags & HTTP_MSGF_XFER_LEN)
htx->extra = 0;
DBG_TRACE_LEAVE(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s);
return ret;
}