HTTP and TXN classes

Dear friends, i need help.

I want to use lua scripting. In particular, i’m interested HTTP class. My target is manipulation response. Example:

local headers = txn.http:req_get_headers()
local host = headers[“host”][0]
txn.http:res_add_header(“X-Custom-Header”, host)

but this header dosen’t set to response. The locate in register_action.
What is it not right?

Also i’m interested txn.set_var method. I want to set many variable for config file. I did so:

txn.set_var(“var1”,“value 1”)

but i can’t use the variable in haproxy.cfg. Please, if it possible, give me something example.

Hi,

you must add this header in the response in a section processing the response, like

http-response lua.XXX

Thierry