develooper Front page | perl.libwww | Postings from October 2001

Re: HTTP::Cookies rejects cookies from host a.b for domain .a.b

Thread Previous | Thread Next
From:
Gisle Aas
Date:
October 26, 2001 15:46
Subject:
Re: HTTP::Cookies rejects cookies from host a.b for domain .a.b
Message ID:
lr669281fw.fsf@caliper.ActiveState.com
Alexandre Duret-Lutz <duret_g@lrde.epita.fr> writes:

> I'm writing an HTTP client for SourceForge using LWP (libwww-perl 5.53).
> 
> I need to login to SourceForge by POSTing a form, to get an
> identification cookie before further processing.
> 
> The trouble is that the (queried) host 'sourceforge.net' sends me a
> cookie as follow:
> 
> Set-Cookie: username=BLABLABLA; expires=Wed, 17-Oct-01 22:37:23 GMT; path=/; domain=.sourceforge.net
> 
> and HTTP::Cookies reject it with the this debug output:
> 
> HTTP::Cookies::extract_cookies: Domain .sourceforge.net does not match host sourceforge.net
> 
> I have no idea who is right, it's the first time I work with
> cookies.  (Reading RFC 2109 I'd vote for HTTP::Cookies, however
> other browsers seems to accept these cookies just fine.)
> 
> I've modified my copy of Cookies.pm as follow to get around this.

Applied.  Thanks!

Regards,
Gisle

> 
> --- Cookies.pm
> +++ Cookies.pm
> @@ -322,7 +322,8 @@
>  
>  	# Check domain
>  	my $domain  = delete $hash{domain};
> -	if (defined($domain) && $domain ne $req_host) {
> +	if (defined($domain)
> +	    && $domain ne $req_host && $domain ne ".$req_host") {
>  	    if ($domain !~ /\./ && $domain ne "local") {
>  	        LWP::Debug::debug("Domain $domain contains no dot");
>  		next SET_COOKIE;

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About