Re: Lua hangs with get line at end of request body
Hi, Very nice, thanks! Confirmed this fixes the issue locally. B. > On 29 Aug 2022, at 14:59, Christopher Faulet wrote: > > Le 8/29/22 à 12:30, Christopher Faulet a écrit : >> There is a bug. I'm able to reproduce it with your lua script. I will fix it >> soon. > > FYI, I pushed a fix[1] to 2.7-DEV. It will be backported soon. > > > [1] https://github.com/haproxy/haproxy/commit/4a20972a > > -- > Christopher Faulet
Re: Lua hangs with get line at end of request body
Le 8/29/22 à 12:30, Christopher Faulet a écrit : There is a bug. I'm able to reproduce it with your lua script. I will fix it soon. FYI, I pushed a fix[1] to 2.7-DEV. It will be backported soon. [1] https://github.com/haproxy/haproxy/commit/4a20972a -- Christopher Faulet
Re: Lua hangs with get line at end of request body
Le 8/26/22 à 18:57, Robert Newson a écrit : Hi All, I'm upgrading some HAproxy nodes here (from 2.0.29 to 2.6.4) and everything is going well except some Lua code I have. I've distilled the code and config to this; haproxy.cfg; global lua-load httpbug.lua defaults mode http timeout client 15 timeout connect 5000 timeout queue 5000 timeout server 36 listen proxy bind 127.0.0.1:10001 http-request use-service lua.httpbug httpbug.lua: core.register_service("httpbug", "http", function(applet) repeat local line = applet:getline() core.log(core.crit, line) until line == '' applet:set_status(200) applet:start_response() applet:send("success") end) -- With a request like 'curl localhost: 10001 -XPOST -T body' and file called 'body' as follows; line1 line2 line3 (where each line is newline-terminated) With 2.0.29 I get a response (of 200 with body "success"), and line1, line2, line3 are logged to screen (haproxy -d -f haproxy.cfg) With 2.6.4 I see the logs of line1, line2, line3, but no response. It appears applet:getline() blocks forever at the end of the request body, rather than returning an empty string to indicate this like it used to (and is documented to do). I searched the mailing list (and SO, etc) for other examples of reading the http request body line by line or for a report of this bug from someone else but found nothing. What did I do wrong? Hi, There is a bug. I'm able to reproduce it with your lua script. I will fix it soon. Thanks ! -- Christopher Faulet
Lua hangs with get line at end of request body
Hi All, I'm upgrading some HAproxy nodes here (from 2.0.29 to 2.6.4) and everything is going well except some Lua code I have. I've distilled the code and config to this; haproxy.cfg; global lua-load httpbug.lua defaults mode http timeout client 15 timeout connect 5000 timeout queue 5000 timeout server 36 listen proxy bind 127.0.0.1:10001 http-request use-service lua.httpbug httpbug.lua: core.register_service("httpbug", "http", function(applet) repeat local line = applet:getline() core.log(core.crit, line) until line == '' applet:set_status(200) applet:start_response() applet:send("success") end) -- With a request like 'curl localhost: 10001 -XPOST -T body' and file called 'body' as follows; line1 line2 line3 (where each line is newline-terminated) With 2.0.29 I get a response (of 200 with body "success"), and line1, line2, line3 are logged to screen (haproxy -d -f haproxy.cfg) With 2.6.4 I see the logs of line1, line2, line3, but no response. It appears applet:getline() blocks forever at the end of the request body, rather than returning an empty string to indicate this like it used to (and is documented to do). I searched the mailing list (and SO, etc) for other examples of reading the http request body line by line or for a report of this bug from someone else but found nothing. What did I do wrong? Regards, Robert Newson