0

The browser wait for some data from server and logging is done only after server restart. Also I see may childs are forked.

$ah{ $r->hostname } ||=  HTML::Mason::ApacheHandler->new ( .. )

sub handle{
    eval{ $ah{ $r->hostname }->handle_request($r); };
    if( $@ ) {
    $r->filename( $r->document_root . '/errors/500.html' );
    $ah{ $r->hostname }->handle_request($r); };
    $r->log_error( 'ERROR' );
    }
}

What I do wrong so they are not finished?

UPD I have found only one note about same problem: http://sourceforge.net/p/mason/mailman/message/14999444/ but no clue.

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158

2 Answers2

1

http://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml

So, instead of passing the error text directly to custom_response we store it in pnotes and set an otherwise unused URI, say /-/error, as custom_response:

sub handler {
  my ($r)=@_;
  @{$r->pnotes}{qw/etext ect/}=("sorry, no access\n", 'text/plain; charset=my-characters');
  $r->custom_response( 403, "/-/error" );
  return 403;
}

Now, we need to configure /-/error to run a Perl handler:

<Location /-/error>
  SetHandler modperl
  PerlResponseHandler My::Error
</Location>

And, of course, we need the handler function, My::Error::handler:

sub handler {
  my ($r)=@_;
  return Apache2::Const::NOT_FOUND unless $r->prev;
  $r->content_type($r->prev->pnotes->{ect});
  $r->print($r->prev->pnotes->{etext});
  return Apache2::Const::OK;
}

This solution seems to work, but I do not know the answer from main question yet: Why request is not finished?

UPD

That seems a bug with mod_perl2 https://bz.apache.org/bugzilla/show_bug.cgi?id=57976

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
0

Your handler doesn't return a proper value. Also, I'm not sure why you think attempting to handle the request a second time if the first one results in an error is a good idea so I have commented that out.

sub handle{
    my $result = eval{ $ah{ $r->hostname }->handle_request($r); };
    if( $@ ) {
      $r->filename( $r->document_root . '/errors/500.html' );
      # $ah{ $r->hostname }->handle_request($r); };
      $r->log_error( 'ERROR' );
    }
    return $result;
}
Dondi Michael Stroma
  • 4,668
  • 18
  • 21
  • Actually I return result in my origin code. I do second request because I want to complete some extra action. Now I save data to pnotes and do internal_redirect instead of handle_request – Eugen Konkov Jun 01 '15 at 13:12