From: Christopher Faulet Date: Wed, 28 Apr 2021 08:50:21 +0000 (+0200) Subject: BUG/MINOR: hlua: Don't consume headers when starting an HTTP lua service X-Git-Tag: v2.4-dev18~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd878d2c73b99797a4780777513fdf9eb3d1d43d;p=thirdparty%2Fhaproxy.git BUG/MINOR: hlua: Don't consume headers when starting an HTTP lua service When an HTTP lua service is started, headers are consumed before calling the script. When it was initialized, the headers were stored in a lua array, thus they can be removed from the HTX message because the lua service will no longer access them. But it is a problem with bodyless messages because the EOM flag is lost. Indeed, once the headers are consumed, the message is empty and the buffer is reset, included the flags. Now, the headers are not immediately consumed. We will skip them if applet:receive() or applet:getline(). This way, the EOM flag is preserved. At the end, when the script is finished, all output data are consumed, thus this remains safe. It is a 2.4-specific bug. No backport is needed. --- diff --git a/src/hlua.c b/src/hlua.c index f2276097f7..426c917de2 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -7419,37 +7419,10 @@ void hlua_applet_http_fct(struct appctx *ctx) /* Set the currently running flag. */ if (!HLUA_IS_RUNNING(hlua) && !(ctx->ctx.hlua_apphttp.flags & APPLET_DONE)) { - struct htx_blk *blk; - size_t count = co_data(req); - - if (!count) { + if (!co_data(req)) { si_cant_get(si); goto out; } - - /* We need to flush the request header. This left the body for - * the Lua. - */ - req_htx = htx_from_buf(&req->buf); - blk = htx_get_first_blk(req_htx); - while (count && blk) { - enum htx_blk_type type = htx_get_blk_type(blk); - uint32_t sz = htx_get_blksz(blk); - - if (sz > count) { - si_cant_get(si); - htx_to_buf(req_htx, &req->buf); - goto out; - } - - count -= sz; - co_set_data(req, co_data(req) - sz); - blk = htx_remove_blk(req_htx, blk); - - if (type == HTX_BLK_EOH) - break; - } - htx_to_buf(req_htx, &req->buf); } /* Executes The applet if it is not done. */