Re: Use an Apache handler after declining another

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 19, 2016 at 2:42 PM, Amlaan Kar <amlaan.kar@xxxxxxxxx> wrote:
> example1_handler is as given below:
> module AP_MODULE_DECLARE_DATA example1_module;
>
> static int example1_handler(request_rec *r)
> {
>     if (!r->handler || strcmp(r->handler, "example1-handler")) return
> (DECLINED);

So it does nothing unless "SetHandler example1-handler" above is effective.

>     ap_set_content_type(r, "text/html");
>     ap_rprintf(r, "Hello, world!");
>     return OK;
> }
[]
>
> Their configuration directives are as given below:
> <Location "/example1">
>     SetHandler example1-handler
> </Location>
>
> <Location "/products.php">
>     SetHandler example5-handler
> </Location>

If you request "/products.php", the handler is set to
"example5-handler", and example1_handler() DECLINEs.

I can't tell about your goal, but if it is to code the first example5
like module only, it probably shouldn't rely on a SetHandler to run
(i.e. the value of r->handler), such that other SetHandler(s)
needed/set by/for other modules could be preserved (not mangled for
the need of your module).

If for example the goal is to activate your module on some specific
locations, those locations could be configured by a directive specific
to your module, like:

  MyModuleEnable "/products.php"

(either a string prefix, repeated as many times as needed, a regexp, whatever).

There are other ways to do this (by setting an environment variable
with for example SetEnvIf, and checking it in your handler), in any
case a DECLINing handler should not have to deal with r->handler
unless it knows which handler to force next.

Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux