codinator
codinator

Reputation: 1

display contents of apr tables in lua

Im trying to display the contents of an apr.table.

Currently, I have a line of code which prints out 'headers_in' of a request object:

log_file:write("headers_in: ",tostring(r.headers_in),"\n")

This returns:

headers_in: Apr.Table: 000001C71F60D448

I have tried running the table through loops to try get any key, value pairs from it, but I keep getting an error, this code:

for k, v in pairs(r.headers_in) do
   log_file:write("Header: ", k, " = ", v, "\n")
end

Returns this:

Lua error: C:/Apache24/htdocs/soap_logger.lua:48: bad argument #1 to 'for iterator' (table expected, got Apr.Table)

Trying any Apr.Table methods, end up returning nil errors:

Lua error: C:/Apache24/htdocs/soap_logger.lua:29: attempt to call a nil value (method 'elts')

Any help would be greatly appreciated

Upvotes: 0

Views: 111

Answers (1)

covener
covener

Reputation: 17896

I think you want r.headers_in_table to treat it as a Lua table. But this answer is specific to r.headers_in.

Upvotes: 0

Related Questions