2015-05-22 54 views
0

當我在HTML ::梅森:: 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' 到瀏覽器?

+0

你應該返回的Apache2 ::常量:: OK或其他適當的Apache2返回值,而不是HTTP狀態。 –

+0

500因爲我忘記使用Apache2 :: RequestIO而返回 –

回答

0

我必須補充use Apache2::RequestIO;我handler.pl

而且我必須更加細心和檢查/var/log/apache2/error.log當事情錯了。

要使用自定義頁面的響應,我可以使用custom_response

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

完整的示例here