libwww-perl / HTTP-Cookies

Objects that represent a "cookie jar"
https://metacpan.org/pod/HTTP::Cookies
Other
4 stars 17 forks source link

HTTP::Cookies::extract_cookies() discards cookies named "expires" [rt.cpan.org #8108] #26

Open oalders opened 7 years ago

oalders commented 7 years ago

Migrated from rt.cpan.org#8108 (status was 'open')

Requestors:

From on 2004-10-24 22:56:15:

According to Netscape's Cookie Specification [1], the first parameter of        a Set-Cookie header is the name and value of the cookie.  This example
below creates a Set-Cookie header with the cookie name equal to
"expires", and then prints out the resulting HTTP::Cookies object. It
should print something like the following:

  Set-Cookie3: expires=10101; path="/"; domain=www.en.com; discard; version=0

Instead, it prints the following, completely eliminating the key and value:

  Set-Cookie3: Discard; path="/"; domain=www.en.com; version=0

Mozilla Firefox, links2, and Internet Explorer all handle cookies with a
name of "expires" properly (that is, they do not discard them.)

#!/usr/bin/perl -w
use strict;
use HTTP::Cookies;
use HTTP::Response;
use HTTP::Request;
my $cookie_jar = new HTTP::Cookies;
my $request = HTTP::Request->new(GET => 'http://www.en.com/');
my $response = HTTP::Response->parse                           
        ("HTTP/1.1 302 Moved\r\nSet-Cookie: expires=10101\r\n\r\n");
$response->request($request);
$cookie_jar->extract_cookies($response);
print $cookie_jar->as_string();
__END__

[1] Client Side State - HTTP Cookies
    Netscape Communications Corporation
    <http://wp.netscape.com/newsref/std/cookie_spec.html>

From on 2004-10-25 07:08:53:

[guest - Sun Oct 24 18:56:15 2004]:

> According to Netscape's Cookie Specification [1], the first parameter
> of        a Set-Cookie header is the name and value of the cookie.

RFC 2019 <http://ftp.ics.uci.edu/pub/ietf/http/rfc2109.txt> makes
this even more clear "The NAME=VALUE attribute-value pair must come
first in each cookie.  The others, if present, can occur in any order."

From on 2006-05-27 00:23:30:

It's my first visit to your website. After just a quick browse, I'm really impressed! 
<a href="http://e.nikolan.harisen.jp/phentermine-lowest-prices.html">Sunslim diet</a> <a href="http://w.bvn.harisen.jp/sunslim-diet.html">Buying phentermine cod</a>  [url]http://c.nikolan.harisen.jp/buying-phentermine-cod.html[/url] [url]http://o.nikolan.harisen.jp/what-size-is-a-european-pillow-sham.html[/url] [url=http://i.nikolan.harisen.jp/negative-side-effects-from-phentermine.html]Diet pills hazards[/url] [url=http://q.bvn.harisen.jp/diet-pills-hazards.html]Deaths by trimspa diet pills[/url] http://o.nikolan.harisen.jp/deaths-by-trimspa-diet-pills.html http://w.bvn.harisen.jp/statistics-of-side-effects-on-diet-pills.html

From on 2006-05-27 02:04:56:

Hello there! Just want to say that I find your site enough interesting for me. Usefull information and all is good arranged. Thank you for your work. I will visit your site more ofter from now and I bookmarked it. 
<a href="http://wedding-decorations.fileplace.biz/teacher-jokes.html">Boston hotel</a> <a href="http://caribean-hotel.fileplace.biz/boston-hotel.html">Bangkok hotel</a>  [url]http://caribean-hotel.fileplace.biz/bangkok-hotel.html[/url] [url]http://refrigerator.tekcities.com/1/refrigeration-diagram-gemap.html[/url] [url=http://refrigerator.tekcities.com/17/internet-refrigeratorsmap.html]Valentines day poems[/url] [url=http://wedding-decorations.fileplace.biz/valentines-day-poems.html]Hotel motel[/url] http://caribean-hotel.fileplace.biz/hotel-motel.html http://wedding-decorations.fileplace.biz/valentine-poems.html

From ether@cpan.org on 2017-01-25 21:38:50:

migrated queues: libwww-perl -> HTTP-Cookies
George-NG commented 7 years ago

As per the code in the first post:

!/usr/bin/perl -w

use strict; use HTTP::Cookies; use HTTP::Response; use HTTP::Request; my $cookie_jar = new HTTP::Cookies; my $request = HTTP::Request->new(GET => 'http://www.en.com/'); my $response = HTTP::Response->parse("HTTP/1.1 302 Moved\r\nSet-Cookie: expires=10101\r\n\r\n"); $response->request($request); $cookie_jar->extract_cookies($response); print $cookie_jar->as_string(); __END__

Executing this with perl5 (revision 5 version 22 subversion 4) with HTTP::Cookies version 6.01 returns the following:

Set-Cookie3: expires=10101; path="/"; domain=www.en.com; discard; version=0