On Thu, Feb 5, 2009 at 11:14 PM, Brian Akins <[email protected]> wrote:
> On 2/5/09 1:51 PM, "Brian McCallister" <[email protected]> wrote:
>
>> Yep, Paul changed the internal impl to be less gross, but in doing so
>> changed the API, i changed the impl to be not gross and restored old
>> API.
>
> Okay I see it now.
>
> I may take a crack at a little performance tuning. Setting up the dispatch
> table every single time doesn't seem necessary. We should be able to just
> do that once at httpd start time.
>
>
> So, if I'm reading that correctly, this should work now as well??
>
> r.content_type
>
> And we would just hack up req_newindex to be able to do
> r.content_type = "application/bakins"
>
> I like the dispatch idea. I'll think about the same for newindex as well...
By the way, for content-type, the dispatch function at the moment is:
if (0 == apr_strnatcmp("content_type", key)) {
const char *value = luaL_checkstring(L, 3);
r->content_type = apr_pstrdup(r->pool, value);
luaL_getmetatable(L, "Apache2.Request");
lua_pushstring(L, value);
lua_setfield(L, -2, "content_type");
lua_pop(L, 1);
return 0;
}
Shouldn't it use ap_set_content_type() instead ?
And I find it weird that, now, to get 'document root', you have to
call r:document_root() instead of r.document_root as it was before.
That's because the dispatch is set like this:
apr_hash_set(dispatch, "document_root", APR_HASH_KEY_STRING,
makefun(&req_document_root, APL_REQ_FUNTYPE_LUACFUN, p));
It could be just:
apr_hash_set(dispatch, "document_root", APR_HASH_KEY_STRING,
makefun(&req_content_encoding_field, APL_REQ_FUNTYPE_STRING,
p));
--
Bertrand Mansion
Mamasam