0

It's related to mod_perl.

I just have one filter specified in my location tag.

<Location /testproj/AServlet>
SetHandler modperl
PerlInputFilterHandler MyApache2::Test3
</Location>

Here, when I hit http://localhost/testproj/AServlet URL in browser. It just hangs. Test3 filter is calling itself again and again. I want to execute Test3 filter just once and pass control to "AServlet" resource.

What shall I do?

Thanks.

keeping_it_simple
  • 439
  • 1
  • 11
  • 31

1 Answers1

1

This is because you are not calling the next filter in the brigade.

package TestFilter;

use base qw(Apache2::Filter);
use Apache2::Const qw(OK);
use APR::Const qw(SUCCESS);

sub handler {
  my ($f, $bb, $mode, $block, $readbytes) = @_;
  my $rv = $f->next->get_brigade($bb, $mode, $block, $readbytes);
  return $rv unless $rv == APR::Const::SUCCESS;

  # do you filtering stuff

  return OK;
}

1;
Rahly
  • 1,462
  • 13
  • 16
  • Thanks Jeremy. The code works great and doesn't call itself again but it doesn't pass-control-to the requested resource ("AServlet"). It shows 'page can't be displayed' with no error in log. – keeping_it_simple Nov 29 '10 at 04:35
  • Also, can you please explain what that 3 line of code is doing? In first line, we are initializing 5 variables. In second line, are we getting reference to next filter? If yes, what is the next filter? I don't have any in my Location tag. In 3rd line, not sure what we are doing... Thanks! – keeping_it_simple Nov 29 '10 at 09:49
  • What is AServlet, because any html file displayed for me. – Rahly Nov 30 '10 at 04:25
  • Remove your PerlResponseHandler, thats the end of the line for a request. Meaning its not going to get to another file/code. – Rahly Nov 30 '10 at 07:58
  • AServlet is mapped to a Servlet in Weblogic Application Server. If I disable all the filters in location tag, it calls AServlet. If filters enabled, it doesn't. – keeping_it_simple Nov 30 '10 at 08:29
  • I don't have any PerlResponseHandler. I just have one filter/handler which is PerlInputFilterHandler as you can see in above location tag. It has your code & a log statement. I am hoping that after logging, it should pass on request (control) to AServlet but it does't... – keeping_it_simple Nov 30 '10 at 08:31
  • You should only have one filter. – Rahly Dec 01 '10 at 03:21
  • Yes, I've only one filter. The problem I am facing is, the actual resource (AServlet in my case) is not getting called after this filter ends. Thanks. – keeping_it_simple Dec 01 '10 at 05:39