Handler enviroment

There is only one global Lua State inside mod_lua, this shouldn't be used for communication or other uses. In the next version, for Apache 2.0, there may be multiples Lua States in mod_lua.

LuaHandlers (Lua function that responds to httpd events), have a slightly different Lua envoirement that an empty Lua state. Follows a description of this environment.

Available libraries:

STANDARD: base, io, string, math, table, loadlib.
SPECIAL: httpd

Httpd library is special because it delivers comunication between Lua code and httpd. This library is not loaded automatically, see LuaRequire directive.

The global Lua State should be used with much zeal, cause it can easily knock down the entire httpd server. Therefore it's strongly recommended to run user's code in a sandbox. See sandbox project.

The LuaHandler must follow the model:

function handler(r) 
  -- DO SOME THING
  return httpd.SOME_STATUS_CODE
end

Parameter "r" is a userdata that links to request_rec of httpd. It can be used freely inside the handler. It is not recommended to keep the parameter r in a place for others "consultations" in requests, because it's closed as soon as request in progress is closed. This is due to httpd's responsability of the lifetime of this structure.

request_rec Interface (the "r" object)

:add_cgi_vars

:add_common_vars

:block_alarms

:content_type

:fileexists

:filename

:getenv

:get_client_block

:hard_timeout

:header_only

:headers_out

:kill_timeout

:log

:remaining

:reset_timeout

:rwrite

:send_http_header

:setup_client_block

:should_cliente_block

:soft_timeout

:status

:unblock_alarms