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

Re: mp2: push_handlers / set_handlers vs. Perl*Handler


Jeremy Nixon wrote:
> Fred Moyer  <suppressed> wrote:
> 
>> But... once I changed my return codes to allow the other handlers to
>> return DECLINED instead of OK in a couple of particular situations,
>> push_handlers() behaved as I would have expected it to.  I'm guessing
>> that your PerlFixupHandler is set to return OK instead of DECLINED
>> somewhere (or maybe not, PerlFixupHandler is RUN_ALL last time I checked).
> 
> Yes, I was returning OK, but since the phases are RUN_ALL I didn't think
> that would matter.  And, when I register multiple handlers all the same
> way, either all in httpd.conf or all with push_handlers, they all run,
> even returning OK.

So I have been playing with different combinations of push_handlers()
and it looks like it's working properly for RUN_FIRST handlers (my
initial success with using DECLINED instead of OK) but not RUN_ALL
handlers. Here's the test case, run make test and check the log to see
which handlers ran.  Anyone?

------------------------

t/conf/extra/conf.in

PerlPostReadRequestHandler My::TestHandler
<Location /test>
   SetHandler modperl
   PerlFixupHandler My::ResponseHandler
   PerlResponseHandler Apache2::Const::OK
</Location>

-----------

t/01.t

#!perl

use strict;

use Apache::Test;
use Apache::TestRequest;

plan tests => 1;

my $res = GET_OK '/test';

----------------

package My::TestHandler;

use strict;
use warnings;

use Apache2::RequestUtil;
use Apache2::Const -compile => qw(OK);
use Apache2::Log;

sub handler {
	my $r = shift;
	$r->log->error(__PACKAGE__ . " handling request $$");
	$r->push_handlers(PerlFixupHandler=> 'My::ExtraResponse');
	#$r->push_handlers(PerlResponseHandler => 'My::ExtraResponse');
	return Apache2::Const::OK;
}
1;

------------------

package My::ResponseHandler;

use strict;
use warnings;

use Apache2::Const -compile => qw(OK DECLINED);
use Apache2::RequestIO;
use Apache2::Log;

sub handler {
	my $r = shift;
	$r->log->error(__PACKAGE__ . " handling request $$");
	return Apache2::Const::DECLINED;
}

1;

-----------------

package My::ExtraResponse;

use strict;
use warnings;

use Apache2::Const -compile => qw(OK DECLINED);
use Apache2::RequestIO;
use Apache2::Log;

sub handler {
	my $r = shift;
	$r->log->error(__PACKAGE__ . " handling request $$");
	return Apache2::Const::OK;
}

1;


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.