嗨,我正在寻找一个Perl RESTful框架,必须:
我只是在做梦,还是可以避免"滚动自己"的做法?
你会推荐什么样的框架?
我一直试图决定我的Web项目是否是使用PSGI实现的候选者,但我真的没有看到它在这个阶段对我的应用程序有什么好处.
我真的不明白所有的大惊小怪.对我来说,PSGI似乎是一个框架,它提供了不同Apache模块之间的通用接口,允许您在它们之间移动应用程序.例如,轻松地将您的应用程序从mod_perl上运行到fastcgi,并提供运行这两个选项的应用程序支持.
是的,还是我错过了什么?
因为我和团队不仅是开发应用程序的一部分,而且几乎都是服务器的维护和设置,我没有看到能够在fastcgi,cgi和mod_perl上运行的价值,我们做只需mod_perl即可.
我误解了PSGI功能,还是不适合我的项目?
它也不适用于prefork.
而use
"D IN startup.pl
,Devel::Cover
问题
Not a CODE reference.
END failed--call queue aborted.
Run Code Online (Sandbox Code Playgroud)
perl 5.8.9,Apache 2.2.13.我的操作系统是FreeBSD,如果重要的话.报告的win32
问题相同.
更新:这是输出PerlTrace all
copying config
restarting apache
mod_perl trace flags dump:
a On (Apache API interaction)
c On (configuration for directive handlers)
d On (directive processing)
e On (environment variables)
f On (filters)
g On (globals management)
h On (handlers)
i On (interpreter pool management)
m On (memory allocations)
o On (I/O)
r …
Run Code Online (Sandbox Code Playgroud) 我试图找出是否有办法在mod_perl 2下完成响应而不返回主处理程序.到目前为止,还没有在文档中找到方法.以下是我正在尝试实现的示例:
#!/usr/bin/perl
# This is some mod_perl handler
use strict;
use warnings;
use Apache2::Const ':common';
sub handler {
my $r = shift;
if ($r->method eq 'POST') {
# just to do something as example
do_post_response($r);
}
$r->content_type('text/plain');
print "Thank you, goodbye.";
return Apache2::Const::OK;
}
sub do_post_response {
my $r = shift;
unless (check_somthing()) {
# Suppose I find a situation that requires
# a different response than normal...
$r->content_type('text/plain');
print "We have a situation...";
$r->something_to_finish_the_request_immediatly(Apache2::Const::OK);
}
}
Run Code Online (Sandbox Code Playgroud)
在一个常规的Perl脚本中,单独运行或在mod_cgi下运行,我可以exit() …
我编写了一个CGI程序,并将HTTP标头的状态错误发送给客户端.但是当我尝试使用mod_perl时,它只响应200 ok状态.如何发送自定义状态代码?
这是我想要回复自定义状态错误时的代码:
my $cgi = new CGI;
print $cgi->header(-type=>"text/html", -charset=>'utf-8', -status=>599);
Run Code Online (Sandbox Code Playgroud)
编辑:
这是代码:
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;
use SessionManagement;
my $cgi = new CGI;
my $method = $cgi->param("method");
my $sessionManagement = new SessionManagement(cgi=>$cgi);
if($sessionManagement){
if (defined($method)) {
if($method eq "authentication") {
loginMethod($cgi,$sessionManagement);
} elsif ($method eq "someMethod"){
someMethod($cgi);
} else{
print $cgi->header(-type=>"text/xml", -charset=>'utf-8');
print "<html>method does not exist</html>";
}
} else {
print $cgi->header(-type=>"text/html", -charset=>'utf-8' , -status=>599);
print "<html>blah blah</html>"; …
Run Code Online (Sandbox Code Playgroud) 我正在编写一些旧代码的单元测试,并发现需要围绕Apache2 :: Request的read()
方法编写一个模拟
my $r = Apache2::Request->new(...);
$r->read(my $buf, $len);
Run Code Online (Sandbox Code Playgroud)
有没有办法在Perl中编写一个函数来填充$buf
?我很确定这样做的唯一方法是使用带有**的XS代码,但我想我至少先问一下.
使用Apache2 :: Request直接导致这种情况,因此我希望嘲笑它.
perl: symbol lookup error: .../APR/Request/Apache2/Apache2.so:
undefined symbol: modperl_xs_sv2request_rec
Run Code Online (Sandbox Code Playgroud) 我在从mod_perl2下运行的一些代码中分配一个长时间运行的进程时遇到了麻烦.
一切都在大部分工作,但似乎分叉的进程持有Apache的日志文件的开放句柄 - 这意味着Apache在进程运行时不会重新启动(我得到'未能打开日志文件'的消息).
这是我正在使用的代码:
use POSIX; # required for setsid
# Do not wait for child processes to complete
$SIG{CHLD} = 'IGNORE';
# fork (and make sure we did!)
defined (my $kid = fork) or die "Cannot fork: $!\n";
if ($kid) {
return (1, $kid);
}else {
# chdir to /, stops the process from preventing an unmount
chdir '/' or die "Can't chdir to /: $!";
# dump our STDIN and STDOUT handles
open STDIN, '/dev/null' or die …
Run Code Online (Sandbox Code Playgroud) 重要更新:问题与Apache或mod_perl无关.最简单的演示:
> perl -le 'use PerlIO::via::QuotedPrint; binmode(\*STDERR, ":via(PerlIO::via::QuotedPrint):utf8"); open (ERROR, ">&STDERR");'
zsh: segmentation fault perl -le
Run Code Online (Sandbox Code Playgroud)
实际上binmode
是由我的代码和open (ERROR, ">&STDERR");
Parse :: RecDescent执行的.
原始问题:
我在mod_perl 2.0.5下遇到了Spreadsheet :: WriteExcel的问题Apache死了有分段错误,我发现它发生 require Parse::RecDescent
在Spreadsheet::WriteExcel
包内的语句中.
strace显示最后发生的事情是重复STDERR:
[pid 31253] dup(2) = 8
[pid 31253] ioctl(8, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffcf66a328) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 31253] lseek(8, 0, SEEK_CUR) = 0
[pid 31253] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
Run Code Online (Sandbox Code Playgroud)
我仔细阅读了代码Parse::RecDescent
和注意到的语句open (ERROR, ">&STDERR");
好吧,经过一些额外的实验,我有这个简约的Plack应用程序来重现段错误:
use …
Run Code Online (Sandbox Code Playgroud) 我们目前在我们的组织中使用5.6版本的perl,以及MySQL和Apache,但现在客户端希望将perl升级到v5.24.
在开始升级之前,必须记住哪些主要变化和关键点?
我冲浪了很多但是从5.6到5.24没有找到任何有趣的东西.
是否可以从这么低的版本升级到高级版本.
有没有人知道如何使用mod_perl2访问/修改POST请求数据.在GET方法中,可以获取/设置请求QUERY字符串:
$args = $r->args();
$prev_args = $r->args($new_args);
Run Code Online (Sandbox Code Playgroud)
如何在POST方法中获取/设置请求QUERY字符串?