如何编写Perl Module程序来检查安全cookie或Httponly标志的cookie属性,并使用测试模块显示结果是否包含secure和Httponly标志.Below是Cookie的代码。请问有人可以给代码。
use strict;
use LWP::simple;
use LWP::UserAgent;
use HTTP::Request;
my $URL = 'https://www.gmail.com/';
my $ua = LWP::UserAgent->new();
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $ua->request($request);
print $_ foreach @ {$response->headers()->{'set-cookie'}};
答案 0 :(得分:0)
以下是一些阅读:http://lwp.interglacial.com/ch11_01.htm
它会将cookie保存到文件中,然后您可以检查该文件:
use HTTP::Cookies;
my $cookie_jar = HTTP::Cookies->new(
file => "/some/where/cookies.lwp",
autosave => 1,
);
my $browser = LWP::UserAgent->new;
$browser->cookie_jar( $cookie_jar );