Hi Jan, This will be fiwed in the next 1.6
- some sample fetches which requires a valid haproxy http transaction, which doesn't exists in Lua land because when the applet start, the transaction is no longer valid are prohibited. - in replacement, a new struct in the AppletHTTP class contains headers and other usefull information. So, for the header you must access to the Lua structs in place of sample fetches, for other things like SSL information you can continue to use the sample fetches (the layer 5 information are available during the applet time). Thierry On Fri, 11 Dec 2015 17:05:58 +0100 Thierry FOURNIER <[email protected]> wrote: > 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 >

