为什么 $r->print 在 mason handler 中打印标准页面?

Why $r->print in mason handler print standart page?

当我在 HTML::Mason::ApacheHandler

sub handler {
    my ($r) = @_;

    $r->content_type('text/plain');
    $r->print( 'YES' );

    $r->log_error( $r->bytes_sent );

    return 200;
}

我得到页面:

OK

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Apache/2.2.22 (Debian) Server at localhost Port 443

如何只打印 'YES' 到浏览器?

我必须将 use Apache2::RequestIO; 添加到我的 handler.pl

而且我必须更加细心,并在出现问题时检查 /var/log/apache2/error.log。

要使用自定义页面进行响应,我可以使用 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;
}

完整示例