From: Christopher Faulet Date: Fri, 14 Dec 2018 12:39:09 +0000 (+0100) Subject: MINOR: lua/htx: Adapt the functions get_in_length and is_full to be HTX aware X-Git-Tag: v1.9-dev11~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a3ceac17e489eb7e990d062ed44ebd7eb67d542f;p=thirdparty%2Fhaproxy.git MINOR: lua/htx: Adapt the functions get_in_length and is_full to be HTX aware --- diff --git a/src/hlua.c b/src/hlua.c index 1be6271f02..245997b752 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -3180,7 +3180,12 @@ __LJMP static int hlua_channel_get_in_len(lua_State *L) MAY_LJMP(check_args(L, 1, "get_in_len")); chn = MAY_LJMP(hlua_checkchannel(L, 1)); - lua_pushinteger(L, ci_data(chn)); + if (IS_HTX_STRM(chn_strm(chn))) { + struct htx *htx = htxbuf(&chn->buf); + lua_pushinteger(L, htx->data - co_data(chn)); + } + else + lua_pushinteger(L, ci_data(chn)); return 1; } @@ -3193,7 +3198,14 @@ __LJMP static int hlua_channel_is_full(lua_State *L) MAY_LJMP(check_args(L, 1, "is_full")); chn = MAY_LJMP(hlua_checkchannel(L, 1)); - rem = b_room(&chn->buf); + if (IS_HTX_STRM(chn_strm(chn))) { + struct htx *htx = htxbuf(&chn->buf); + + rem = htx_free_data_space(htx); + } + else + rem = b_room(&chn->buf); + rem -= global.tune.maxrewrite; /* Rewrite reserved size */ lua_pushboolean(L, rem <= 0);