Strawberry Perl 和 mod_perl2 下出现奇怪的 Apache2::Cookie 错误

发布于 2024-10-01 19:40:29 字数 620 浏览 6 评论 0原文

我有一组在 ActivePerl 5.10 下运行的脚本。但是,在 Strawberry Perl 5.10 下,我收到一条奇怪的错误消息:

Can't locate object method "cookie_class" via package "MyCookie" (perhaps you forgot to load "MyCookie"?) at C:/strawberry/perl/site/lib/Apache2/Cookie.pm line 41.

然而,MyCookie 是 cookie 本身的名称,而不是任何 Perl 包的名称。

如果我注释掉 Cookie.pm 的第 41 行,脚本会运行,但我无法再成功获取或设置 cookie。

错误消息似乎有些正确,因为我也找不到 cookie_class(除了 POD 文件中提到的地方)。也就是说,我的 ActivePerl 安装也是如此。

我认为它在 C:\strawberry\perl\site\lib\auto\APR\Request\Request.dll 中——为什么在 Strawberry 下找不到它,但在 ActivePerl 下可以找到它?

I have a set of scripts that run under ActivePerl 5.10. However, under Strawberry Perl 5.10, I get a strange error message:

Can't locate object method "cookie_class" via package "MyCookie" (perhaps you forgot to load "MyCookie"?) at C:/strawberry/perl/site/lib/Apache2/Cookie.pm line 41.

However, MyCookie is the name of the cookie itself, not any Perl package.

If I comment out line 41 of Cookie.pm, the script runs, but I cannot successfully get or set cookies anymore.

The error message seems somewhat correct in that I can't find cookie_class either (except where it's mentioned in the POD files.) That said, the same is true for my ActivePerl installation.

I think it's in C:\strawberry\perl\site\lib\auto\APR\Request\Request.dll--how come it can't find it under Strawberry, but can under ActivePerl?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如歌彻婉言 2024-10-08 19:40:29

更改您的代码以使用 2.X 方案,如下所示:

my $j = Apache2::Cookie::Jar->new($r);
my $cookie = $j->cookies("MyCookie"); # works!  go figure...

而不是旧方法:(

local our %cookies = Apache2::Cookie->fetch($r); # error was happening here
local our $cookie = $cookies{"MyCookie"};

出于某种原因,这似乎可以修复它。)

Change your code to use the 2.X scheme like so:

my $j = Apache2::Cookie::Jar->new($r);
my $cookie = $j->cookies("MyCookie"); # works!  go figure...

Rather than the old method:

local our %cookies = Apache2::Cookie->fetch($r); # error was happening here
local our $cookie = $cookies{"MyCookie"};

(For some reason this seemed to fix it.)

守望孤独 2024-10-08 19:40:29

您是否可能在 Strawberry 和 ActivePerl 版本之间混合使用 apreq DLL?或者以某种方式混合 apreq-1 和 apreq-2 DLL?

有问题的 cookie_class 调用周围的区域就是这样:

my $jar = $req->jar or return;
$jar->cookie_class(__PACKAGE__);
return $jar->get(shift) if @_;

cookie_class 方法确实来自 Request.dll$req 在调用 jar() 之前进行类型检查。

Are you possibly mixing the apreq DLLs between the Strawberry and ActivePerl versions? Or mixing apreq-1 and apreq-2 DLLs somehow?

The area around the offending cookie_class call is just this:

my $jar = $req->jar or return;
$jar->cookie_class(__PACKAGE__);
return $jar->get(shift) if @_;

The cookie_class method does come from Request.dll and $req is type checked before jar() is called.

甩你一脸翔 2024-10-08 19:40:29

在某个地方,您或其他人正在将字符串传递给需要对象的函数。调试的最佳第一步是加载 Carp::Always 以便您可以获得回溯并找出到底发生了什么。

Somewhere, you or someone else is passing a string to a function that expects an object. Your best first step in debugging would be to load Carp::Always so that you can get a backtrace and find out what's really happening.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文