MEDIUM: hlua: Add function to change the body length of an HTTP Message
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 May 2025 12:10:31 +0000 (14:10 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 20 May 2025 16:19:20 +0000 (18:19 +0200)
commitf9d6273e2bd0adf4a43f679ec8f7fdee1627a3f0
treead2259b10655642613adcaaea81054941c261edf
parentab22d6b37d9ca2655f5247ca85d33734472e38e8
MEDIUM: hlua: Add function to change the body length of an HTTP Message

There was no function for a lua filter to change the body length of an HTTP
Message. But it is mandatory to be able to alter the message payload. It is
not possible update to directly update the message headers because the
internal state of the message must also be updated accordingly.

It is the purpose of HTTPMessage.set_body_len() function. The new body
length myst be passed as argument. If it is an integer, the right
"Content-Length" header is set. If the "chunked" string is used, it forces
the message to be chunked-encoded and in that case the "Transfer-Encoding"
header.

This patch should fix the issue #2837. It could be backported as far as 2.6.

(cherry picked from commit 94055a5e73e9feed8c0aed8cae751e1896be90bd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 8ac8358e06c8be8260a36d1e76d4078aa50081ff)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
doc/lua-api/index.rst
src/hlua.c