]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: payload/htx: Adapt smp_fetch_len to be HTX aware
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Dec 2018 12:44:53 +0000 (13:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Dec 2018 15:03:34 +0000 (16:03 +0100)
include/proto/proto_http.h
src/payload.c

index 1d210336fdf869f0a051ac1a8f18c32c1a56da7d..2e2163ee5db03e49e4dd7861cad78a20728d9bf5 100644 (file)
@@ -27,6 +27,7 @@
 #include <types/stream.h>
 #include <types/task.h>
 #include <proto/channel.h>
+#include <proto/stream.h>
 
 #define IS_HTX_STRM(strm) (strm_fe(strm)->options2 & PR_O2_USE_HTX)
 #define IS_HTX_SMP(smp)   ((smp)->strm && IS_HTX_STRM((smp)->strm))
index 14191a7e20e0a758715904dec227e1c90040cae6..7ef6d97e224f389c6012b5bf499a1465046aa680 100644 (file)
 
 #include <common/initcall.h>
 #include <common/net_helper.h>
+#include <common/htx.h>
 #include <proto/acl.h>
 #include <proto/arg.h>
 #include <proto/channel.h>
 #include <proto/pattern.h>
 #include <proto/payload.h>
 #include <proto/sample.h>
+#include <proto/proto_http.h>
 
 
 /************************************************************************/
@@ -53,7 +55,12 @@ smp_fetch_len(const struct arg *args, struct sample *smp, const char *kw, void *
 
        chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
        smp->data.type = SMP_T_SINT;
-       smp->data.u.sint = ci_data(chn);
+       if (IS_HTX_SMP(smp)) {
+               struct htx *htx = htxbuf(&chn->buf);
+               smp->data.u.sint = htx->data - co_data(chn);
+       }
+       else
+               smp->data.u.sint = ci_data(chn);
        smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE;
        return 1;
 }