0

如何编写 Perl 模块程序来检查安全 cookie 或 Httponly 标志的 cookie 属性,并使用测试模块显示结果是否包含安全和 Httponly 标志。以下是 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'}};
4

1 回答 1

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 );
于 2013-07-03T07:44:18.957 回答