httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Lewis <jle...@silverhawk.net>
Subject Re: best way to return the content of a file
Date Sun, 19 Aug 2012 14:14:32 GMT
Yes. Every virtual host should be able to have a separate configuration,
hence different configs. The server_rec structure points to the virtual
host. There are ways to get the global settings from the global server_rec,
do some searches.on the list archives and you will find that if its what
you needed.

Joe
--
Http://www.silverhawk.net/
On Aug 19, 2012 3:49 AM, "nik600" <nik600@gmail.com> wrote:

> On Sat, Aug 18, 2012 at 7:18 PM, nik600 <nik600@gmail.com> wrote:
> > 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
>
> Ok, i was missing the create_dir_conf and merge_dir_conf handlers.
>
> One more thing (i hope the last :-) ) when the documentation talk
> about  server configuration handler/merge it is intended by vhost?
>
> Thanks
> --
> /*************/
> nik600
> http://www.kumbe.it
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message