Skip Menu |
 

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 27347
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: tmetro [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 5.803
Fixed in: (no value)



Subject: $netloc parameter handled inconsistently in LWP::UserAgent
In LWP::UserAgent: The method to store credentials looks like this: sub credentials { my($self, $netloc, $realm, $uid, $pass) = @_; @{ $self->{'basic_authentication'}{lc($netloc)}{$realm} } = ($uid, $pass); } where the $netloc parameter, aside from being lowercased, gets used verbatim as a hash key, yet the method used to retrieve credentials: sub get_basic_credentials { my($self, $realm, $uri, $proxy) = @_; ... my $host_port = lc($uri->host_port); ... return @{ $self->{'basic_authentication'}{$host_port}{$realm} }; is taking $uri - equivalent to $netloc - and is processing it via URI before using it as a hash key. I suggest patching credentials as follows: sub credentials { my($self, $netloc, $realm, $uid, $pass) = @_; + my $loc = lc(URI->new($netloc)->host_port); - @{ $self->{'basic_authentication'}{lc($netloc)}{$realm} } = + @{ $self->{'basic_authentication'}{}{$realm} } = ($uid, $pass); } Also, the documentation for credentials() is really too sparse. Let me know if you want a patch. -Tom
From: SREZIC [...] cpan.org
Download (untitled) / with headers
text/plain 1.4k
On Wed May 30 18:27:55 2007, tmetro@cpan.org wrote: Show quoted text
> In LWP::UserAgent: > > The method to store credentials looks like this: > > sub credentials > { > my($self, $netloc, $realm, $uid, $pass) = @_; > @{ $self->{'basic_authentication'}{lc($netloc)}{$realm} } = > ($uid, $pass); > } > > where the $netloc parameter, aside from being lowercased, gets used > verbatim as a hash key, yet the method used to retrieve credentials: > > sub get_basic_credentials > { > my($self, $realm, $uri, $proxy) = @_; > ... > my $host_port = lc($uri->host_port); > ... > return @{ $self->{'basic_authentication'}{$host_port}{$realm} }; > > is taking $uri - equivalent to $netloc - and is processing it via URI > before using it as a hash key. > > I suggest patching credentials as follows: > > sub credentials > { > my($self, $netloc, $realm, $uid, $pass) = @_; > + my $loc = lc(URI->new($netloc)->host_port); > - @{ $self->{'basic_authentication'}{lc($netloc)}{$realm} } = > + @{ $self->{'basic_authentication'}{}{$realm} } = > ($uid, $pass); > } > > > Also, the documentation for credentials() is really too sparse. Let me > know if you want a patch. > > -Tom
It seems to me that $loc is missing in the patched line. Probably it should be: + @{ $self->{'basic_authentication'}{$loc}{$realm} } = Otherwise, I stumbled over the same problem and would be content if credentials' $netloc was documented to be in the host:port form. Regards, Slaven
Download (untitled) / with headers
text/plain 110b
This has been resolved by documenting the format of the $netloc argument to $ua->credentials. See [RT#31969].


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.