]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: filters/htx: Don't rely on HTX extra field if payload is filtered
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 20 Jun 2023 11:34:46 +0000 (13:34 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 20 Jun 2023 11:34:46 +0000 (13:34 +0200)
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.

src/filters.c

index 8910fc2684847b6b4916433a4b3be3d579fb3beb..e55adee6b4fce6031600b40cda8cac9e22b932b0 100644 (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;
 }