0

浏览器等待来自服务器的一些数据,并且仅在服务器重新启动后才完成日志记录。我也看到可能孩子是分叉的。

$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' );
    }
}

我做错了什么,所以他们没有完成?

UPD 我只发现一个关于同一问题的注释:http: //sourceforge.net/p/mason/mailman/message/14999444/但没有线索。

4

2 回答 2

1

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

因此,我们没有将错误文本直接传递给 custom_response,而是将其存储在 pnotes 中,并设置一个其他未使用的 URI,例如 /-/error,作为 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;
}

现在,我们需要配置 ///error 来运行 Perl 处理程序:

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

当然,我们还需要处理函数 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;
}

这个解决方案似乎有效,但我还不知道主要问题的答案:为什么请求没有完成?

UPD

这似乎是 mod_perl2 https://bz.apache.org/bugzilla/show_bug.cgi?id=57976的错误

于 2015-05-23T16:04:06.907 回答
0

您的处理程序没有返回正确的值。另外,我不确定为什么您认为如果第一次导致错误,则尝试第二次处理该请求是个好主意,所以我已将其注释掉。

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;
}
于 2015-05-31T21:58:26.623 回答