Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP::Cookies don't add ".domain" cookies to "domain" requests [rt.cpan.org #49898] #29

Open
oalders opened this issue Mar 30, 2017 · 1 comment

Comments

@oalders
Copy link
Member

oalders commented Mar 30, 2017

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

Requestors:

Attachments:

From [email protected] on 2009-09-22 05:18:09:

Cookie:
Set-Cookie: dotdomain=1; path=/; domain=.moikrug.ru

not passed to request:
GET http://moikrug.ru/

Additional tests for t/base/cookies.t included.

From [email protected] on 2010-08-08 20:23:44:

I confirm the problem. RFC 2965 does not have concrete example of
matching "domain.com" against ".domain.com".

The current workaround is to specify "host" header separately:

my $ua = LWP::UserAgent->new();
my $cookie = HTTP::Cookies->new(
    file => '/tmp/cookies.txt',
    autosave => 1
);
my $r = HTTP::Request::Common::GET('http://host.com', host =>
'www.host.com');
$ua->prepare_request($r);
$cookie->add_cookie_header($r);
print Data::Dumper->Dump([\$r], ["r"]);

Sergey, if you have a patch for Cookies.pm, you are welcome to attach it.

From [email protected] on 2017-01-25 21:39:08:

migrated queues: libwww-perl -> HTTP-Cookies
@jackdeguest
Copy link

Simple solution to this problem is simply to add the following line in the sub add_cookie_header right after the line:
$domain = "$domain.local" unless $domain =~ /./;
you add:
$domain = ".$domain" unless( $domain =~ /^./ );
and problem solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants