From da9d8e14bea78f0586c9183c2a77e7b14a7fb146 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 18 Jul 2025 11:14:26 +0200 Subject: [PATCH] BUG/MINOR: hlua: Skip headers when a receive is performed on an HTTP applet When an HTTP applet tries to retrieve data, the request headers are still in the buffer. But, instead of being silently removed, their size is removed from the amount of data retrieved. When the request payload is fully retrieved, it is not an issue. But it is a problem when a length is specified. The data are shorten from the headers size. So now, we take care to silently remove headers. This patch must be backported to all stable versions. (cherry picked from commit 5b5ecf848dbe7467afb67ea70951b4e56f39dab5) Signed-off-by: Willy Tarreau (cherry picked from commit 8daaeb14e8e89c936a82a4ddff9c54dc1c93b92b) Signed-off-by: Christopher Faulet (cherry picked from commit 0c62785f34fd14d612985e0a8b01d57540b136f2) Signed-off-by: Christopher Faulet --- src/hlua.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hlua.c b/src/hlua.c index 8ee76f2..967145f 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -5906,6 +5906,8 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon case HTX_BLK_DATA: v = htx_get_blk_value(htx, blk); luaL_addlstring(&luactx->b, v.ptr, vlen); + if (len > 0) + len -= vlen; break; case HTX_BLK_TLR: @@ -5919,8 +5921,6 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon c_rew(req, vlen); count -= vlen; - if (len > 0) - len -= vlen; if (sz == vlen) blk = htx_remove_blk(htx, blk); else { -- 1.7.10.4