Chinaunix
标题:
lwp已经添加了cookie_jar 为什么服务器还是返回 Set-Cookie
[打印本页]
作者:
yakczh_cu
时间:
2016-03-28 14:05
标题:
lwp已经添加了cookie_jar 为什么服务器还是返回 Set-Cookie
use 5.01;
use HTTP::Request;
use LWP::UserAgent;
use HTTP::Cookies;
use Data::Dumper;
my $url='http://bbs.chinaunix.net';
my $cookie_jar = HTTP::Cookies->new( file => 'cookie.dat' , autosave => 1,ignore_discard=>1);
my $ua = LWP::UserAgent->new(agent=> 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6');
$ua->cookie_jar($cookie_jar);
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
say $req->as_string;
# HTML back
if ($res->is_success)
{
say $res->headers->as_string;
}
复制代码
如果浏览器请求已经添加了 Cookie头 ,服务器不应该再返回 Set-Cookie 但是运行结果还是返回
et-Cookie: ndfU_81a3_sid=6RB2I3; expires=Tue, 29-Mar-2016 06:02:30 GMT; Max-Age=86400; path=/; domain=.chinaunix.net
Set-Cookie: ndfU_81a3_lastact=145914950%09forum.php%09; expires=Tue, 29-Mar-2016 06:02:30 GMT; Max-Age=86400; path=/; domain=.chinaunix.net
Set-Cookie: ndfU_81a3_cloudstatpost=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=.chinaunix.net
Set-Cookie: ndfU_81a3_sid=6RB2I3; expires=Tue, 29-Mar-2016 06:02:30 GMT; Max-Age=86400; path=/; domain=.chinaunix.net
作者:
tmp
时间:
2016-03-29 07:58
"服务器不应该再返回 Set-Cookie" 为什么不应该?
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2