httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian McCallister <>
Subject Re: [PATCH] mod_wombat: add table_get and table_set
Date Fri, 27 Apr 2007 18:34:01 GMT
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']

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.



View raw message