从 PerlInputFilterHandler 生成响应时出错
我的 httpd.conf 位置标记中只有一个过滤器:
<Location /testproj/A>
SetHandler modperl
PerlInputFilterHandler MyApache2::Test
</Location>
Test 是一个 PerlInputFilterHandler。
如果我在此过滤器中遵循以下代码:
package MyApache2::Test10;
use strict;
use Apache2::Const qw(OK);
use Apache2::Filter ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
sub handler {
my $f = shift;
#my $buf = '';
#while($f->read(my $tempbuf, 1024)) {
# $buf = $tempbuf;
#}
my $r = $f->r;
$r->content_type("text/html\n\n");
$r->print("welcome!!!");
return OK;
}
1;
它会生成响应 - 换句话说,它会发送“欢迎!!!”到浏览器。
但是,如果我遵循代码(启用注释代码):
package MyApache2::Test10;
use strict;
use Apache2::Const qw(OK);
use Apache2::Filter ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
sub handler {
my $f = shift;
my $buf = '';
while($f->read(my $tempbuf, 1024)) {
$buf = $tempbuf;
}
my $r = $f->r;
$r->content_type("text/html\n\n");
$r->print("welcome!!!");
return OK;
}
1;
这不起作用。 “欢迎!!!”不会转到浏览器 - '404' 会。
你能在这里建议一些东西吗?
非常感谢!
I just have one filter in my location tag of httpd.conf:
<Location /testproj/A>
SetHandler modperl
PerlInputFilterHandler MyApache2::Test
</Location>
Test is an PerlInputFilterHandler.
If I've following code in this filter:
package MyApache2::Test10;
use strict;
use Apache2::Const qw(OK);
use Apache2::Filter ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
sub handler {
my $f = shift;
#my $buf = '';
#while($f->read(my $tempbuf, 1024)) {
# $buf = $tempbuf;
#}
my $r = $f->r;
$r->content_type("text/html\n\n");
$r->print("welcome!!!");
return OK;
}
1;
It generates response - in other words, it sends "welcome!!!" to browser.
However if I've following code (enables commented code):
package MyApache2::Test10;
use strict;
use Apache2::Const qw(OK);
use Apache2::Filter ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
sub handler {
my $f = shift;
my $buf = '';
while($f->read(my $tempbuf, 1024)) {
$buf = $tempbuf;
}
my $r = $f->r;
$r->content_type("text/html\n\n");
$r->print("welcome!!!");
return OK;
}
1;
This doesn't work. The "welcome!!!" doesn't go to the browser - '404' does.
Can you suggest something here?
Thanks very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在代码中省略了
use warnings;
——将其放入,您将在错误日志中获得有关失败代码的更多信息。显然,有关读取输入缓冲区的某些操作不起作用。You are omitting
use warnings;
from your code -- put that in and you will get more information about failing code in your error log. Clearly something about reading the input buffer is not working.