Hello, Thank you for the bug repport and the method for reproducing it.
You're absolutely right, I reproduce the bug. Unfortunately it's not a bug. When we enter in the applet run, the data of the body is received, and when the body data is received, HAProxy looses the offset headers. So, you cannot retrieve the header content when a post is received :( I wrote a patch which copy the header names and values in an Lua array. Its running, but it reveal another bug ;) I fix all of these and I submit the patch. This patch modify the API, so I'm not sure that it will be embed in the 1.6. Thierry On Fri, 11 Dec 2015 11:49:49 +0100 "Jan A. Bruder" <[email protected]> wrote: > Hi, > > applet.sf:hdr(name) always returns empty strings in POST requests. It works > only in GET requests. > > To reproduce: > > haproxy.cfg: > global > ... > lua-load /etc/haproxy/test.lua > ... > > frontend http > bind *:8081 > mode http > acl applet_test_url path /applet-test > http-request use-service lua.applet-test if applet_test_url > default_backend be > ... > > test.lua: > > -- applet test endpoint > core.register_service("applet-test", "http", function(applet) > local headerContentType = applet.sf:hdr("Content-Type") > core.Info("headerContentType:" .. headerContentType) > local headerUserAgent = applet.sf:hdr("User-Agent") > core.Info("headerUserAgent:" .. headerUserAgent) > local src = applet.sf:src() > core.Info("src:" .. src) > > local response = headerContentType .. " + " .. headerUserAgent .. " + " .. > src > > applet:set_status(200) > applet:add_header("content-length", string.len(response)) > applet:add_header("content-type", "text/plain") > applet:start_response() > applet:send(response) > end) > > curl -X GET -H "Content-Type: text/plain" http://127.0.0.1:8081/applet-test > > ==> applet.sf:hdr() returns the correct values > > curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d > "key=value" http://127.0.0.1:8081/applet-test > > ==> applet.sf:hdr() returns empty strings

