httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nik600 <nik...@gmail.com>
Subject Re: best way to return the content of a file
Date Sat, 18 Aug 2012 17:18:33 GMT
On Sat, Aug 18, 2012 at 6:32 PM, Eric Covener <covener@gmail.com> wrote:
>> i'm enabling my module with a Location directive:
>>
>>     <Location /data>
>>     SetHandler kcache
>>     </Location>
>>
>> and i want to control the execution of the module with an initial check:
>>
>> if (!r->handler || strcmp(r->handler, "kcache")) return (DECLINED);
>>
>> but r->handler is null if the hook is called in ap_hook_translate_name
>> state, so how can i check this condition?
>
> You can't check that condition early.  You should implement a
> directive to enable your module in these early phases.

i've done that, and i've set the configuration per-directory, but it
seems that is have every time the same value, even if called from
different locations:

static const command_rec        kcache_directives[] =
{
    AP_INIT_TAKE1("KcacheEnabled", kcache_set_enabled, NULL,
ACCESS_CONF, "KcacheEnabled must have Off or On value"),
    AP_INIT_TAKE1("KcachePath", kcache_set_path, NULL, ACCESS_CONF,
"KcachePath must contain the path"),
    { NULL }
};


static void register_hooks(apr_pool_t* pool)
{

	/*
	* imposto i valori di default
	*/
	config.enabled=FALSE;
	config.path="/var/www";

	static const char *succ[] = {"mod_proxy.c","mod_alias.c", NULL};	
    ap_hook_translate_name(kcache_handler, NULL, succ, APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA kcache_module = {
    STANDARD20_MODULE_STUFF,
    NULL,
    NULL,
    NULL,
    NULL,
    kcache_directives,
    register_hooks
};

then i have:
in the global config
<Directory />
	   KcacheEnabled Off
</Directory>
and in a specific vhost:
    <Directory "/var/www/kcache/trunk/data">
        KcacheEnabled On
   	KcachePath /var/www/data
     </Directory>

finally i've added in my handler:

static int kcache_handler(request_rec* r)
{
	apr_status_t s;	

	ap_log_rerror(APLOG_MARK, APLOG_DEBUG,s,r,"KcacheEnabled = %i",config.enabled);
	ap_log_rerror(APLOG_MARK, APLOG_DEBUG,s,r,"KcachePath = %s",config.path);
	if(!config.enabled){
	    ap_log_rerror(APLOG_MARK, APLOG_NOTICE,s,r,"KcacheEnabled = Off,
exiting from kcache");
    	return DECLINED;
	
	}
...
...

but looking at logs it seems that KcacheEnabled is always On.

Is my approach correct?

Thanks




-- 
/*************/
nik600
http://www.kumbe.it

Mime
View raw message