抑制“日子太大” Perl LWP::UserAgent 中的警告

发布于 2024-08-20 04:12:52 字数 1065 浏览 4 评论 0原文

我有一个相当简单的 Perl 脚本,使用 LWP::UserAgent 模块通过重定向跟踪 URL,找到最终的目标 URL,然后将其存储在我们的 MySQL 数据库中。问题是,脚本有时会报告如下所示的警告:

Day too big - 25592 > 24855
Sec too small - 25592 < 74752
Sec too big - 25592 > 11647
Day too big - 25592 > 24855
Sec too small - 25592 < 74752
Sec too big - 25592 > 11647

警告没有提供任何其他详细信息来说明为什么会发生这种情况或哪个模块导致了问题,但我很确定它与LWP::用户代理。

我使用以下代码初始化代理:

use LWP::UserAgent;
my $ua = LWP::UserAgent->new(cookie_jar => { },requests_redirectable => [ ]);
$ua->agent('Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:9.9.9.9) Gecko/20079999 Firefox/2.0.0.1');
$ua->timeout(10);

我在线搜索,发现的唯一结果是以下线程,该线程从未解析http://www.mail-archive.com/[电子邮件受保护]/ msg06515.html。线程作者认为这些警告在某种程度上与 LWP::UserAgent 模块捕获的 cookie 日期有关。

该警告似乎不会影响脚本,但我希望能够帮助您更好地理解可能导致此问题的原因以及如何解决该问题或至少抑制警告消息的建议。预先感谢您的帮助!

I have a fairly simple perl script with uses the LWP::UserAgent module to follow URLs through redirection to find the final destination URL which it then stores in our MySQL database. The problem is that from time to time the script reports warnings that look like this:

Day too big - 25592 > 24855
Sec too small - 25592 < 74752
Sec too big - 25592 > 11647
Day too big - 25592 > 24855
Sec too small - 25592 < 74752
Sec too big - 25592 > 11647

The warnings don't provide any other details as to why this is happening or which module is causing the issue but I'm pretty sure it has to do with LWP::UserAgent.

I'm initializing the agent using the following code:

use LWP::UserAgent;
my $ua = LWP::UserAgent->new(cookie_jar => { },requests_redirectable => [ ]);
$ua->agent('Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:9.9.9.9) Gecko/20079999 Firefox/2.0.0.1');
$ua->timeout(10);

I searched online and the only result I found was to the following thread which was never resolved http://www.mail-archive.com/[email protected]/msg06515.html. The thread author thought that these warning were somehow related to cookie dates being captured by the LWP::UserAgent module.

The warning doesn't seem to be effecting the script but I would appreciate any help in better understanding what might be causing this issue and advice on how to resolve it or at least suppress the warning messages. Thanks in advance for your help!

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

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

发布评论

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

评论(2

〃温暖了心ぐ 2024-08-27 04:12:52

如果升级不适合您,您当然可以始终使用本地 $SIG{__WARN__} 处理程序过滤掉警告。

{
    local $SIG{__WARN__} = sub {
        warn @_ unless $_[0] =~ m(^.* too (?:big|small));
    };
    # your code here.
}

If upgrading is not an option for you, you can, of course always filter out the warnings using a local $SIG{__WARN__} handler.

{
    local $SIG{__WARN__} = sub {
        warn @_ unless $_[0] =~ m(^.* too (?:big|small));
    };
    # your code here.
}
很糊涂小朋友 2024-08-27 04:12:52

请参阅更改

2009-10-06 发布5.833

吉斯尔·阿斯 (5):

  • 处理在很远的将来就会过期的 Cookie [RT#50147]
  • 处理在纪元或之前过期的 Cookie [RT#49467]

看起来您需要升级到LWP 的最新版本。

See Changes:

2009-10-06 Release 5.833

Gisle Aas (5):

  • Deal with cookies that expire far into the future [RT#50147]
  • Deal with cookies that expire at or before epoch [RT#49467]

It looks like you need to upgrade to the most recent version of LWP.

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