From: Christopher Faulet Date: Thu, 7 Apr 2022 08:07:18 +0000 (+0200) Subject: BUG/MEDIUM: hlua: Don't set EOM flag on an empty HTX message in HTTP applet X-Git-Tag: v2.6-dev5~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f89af9c20597d8a0bf741559e1650fe3af5f2f25;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: hlua: Don't set EOM flag on an empty HTX message in HTTP applet In a lua HTTP applet, when the script is finished, we must be sure to not set the EOM on an empty message. Otherwise, because there is no data to send, the mux on the client side may miss the end of the message and consider any shutdown as an abort. See "UG/MEDIUM: stats: Be sure to never set EOM flag on an empty HTX message" for details. This patch must be backported as far as 2.4. On previous version there is still the EOM HTX block. --- diff --git a/src/hlua.c b/src/hlua.c index ea75b16eb5..ee48323d55 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -9567,7 +9567,19 @@ void hlua_applet_http_fct(struct appctx *ctx) if (!(ctx->ctx.hlua_apphttp.flags & APPLET_HDR_SENT)) goto error; - /* no more data are expected. Don't add TLR because mux-h1 will take care of it */ + /* no more data are expected. If the response buffer is empty + * for a chunked message, be sure to add something (EOT block in + * this case) to have something to send. It is important to be + * sure the EOM flags will be handled by the endpoint. + */ + if (htx_is_empty(res_htx) && (strm->txn->rsp.flags & (HTTP_MSGF_XFER_LEN|HTTP_MSGF_CNT_LEN)) == HTTP_MSGF_XFER_LEN) { + if (!htx_add_endof(res_htx, HTX_BLK_EOT)) { + si_rx_room_blk(si); + goto out; + } + channel_add_input(res, 1); + } + res_htx->flags |= HTX_FL_EOM; si->cs->flags |= CS_FL_EOI; res->flags |= CF_EOI;