[Israel.pm] mod_perl question: Ending an apache request withan OK status inside a PerlFixupHandler?
Issac Goldstand
margol at beamartyr.net
Wed Apr 28 08:55:36 PDT 2004
----- Original Message -----
From: "Yuval Yaari" <yuval at windax.com>
To: "Perl in Israel" <perl at perl.org.il>
Sent: Wednesday, April 28, 2004 6:44 PM
Subject: Re: [Israel.pm] mod_perl question: Ending an apache request withan
OK status inside a PerlFixupHandler?
> I tried:
> $template->process($file, $vars, $r) or do {
> $r->log_error($template->error(), $file); return
> Apache::Constants::DECLINED(); };
> return Apache::Constants::FORBIDDEN();
>
> And it gives me the right results, AND sends headers (again) and
> "Forbidden You don't have permission to access.......".
> It doesn't call the next handler though.
>
> To be honest I did manage to do what I want but I don't like the
> implementation.
>
> I store the template output in a scalar, and then:
> $r->custom_response(Apache::Constants::FORBIDDEN(), $ttoutput);
> return Apache::Constants::FORBIDDEN();
>
This is the correct way to do it.
> Also since I put it all in a subroutine called report_error, I call it
> (from the handler subroutine) as "return report_error" - is there a way
> to return the status from inside that subroutine (just to make
> everything look nicer, it's really not that important)?
You *are* returning status. The status is FORBIDDEN.
Apache won't let you send content if a handler decides to abort the handler
chain. That's what you're doinbg with custom_response: setting the content
to be returned with the forbidden error code.
>
> Thanks,
> --Yuval
>
> Issac Goldstand wrote:
>
> >Don't return OK. Return FORBIDDEN from the fixuphandler too.
> >
> >
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://www.perl.org.il/mailman/listinfo/perl
>
More information about the Perl
mailing list