On Apr 27, 2007, at 10:48 AM, Akins, Brian wrote:

Probably not the best way to do this, but adds ability to get/set on
r->headers_in and r->headers_out

Example usage:

function handle(r)
  r:table_set(r.headers_out, "Lua", "Cool");
  val = r:table_get(r.headers_in, "User-Agent");
  r:puts("User-Agent: " .. val .. "\n");
End

FWW, I had never done any lua until this morning, so I'm sure it can be done better. I'm not a huge fan of just wrapping apr_table_get/set, but wasn't sure if I shoved them into a lua table that I could keep them (the apr table
and the lua table) in sync.

Very nice, thank you!

We may want to consider not putting table_set and table_get on the request, though. It might be better to have a general purpose userdata type (metatable) for apr_table_t and put the functions there. This would allow for something like:

function handle(r)
  r.headers_out['Lua'] = 'Cool'
  val = r.headers_in['User-Agent']
end

where we use an apw_push_apr_table(L, r->headers_out) to push the headers onto the Lua "request" and apw_check_apr_table(...) to pull it back off. This would save special cases for all the additional apr_table_t usages, as well.

Thoughts?

-Brian

Reply via email to