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
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
This has been resolved by documenting the format of the $netloc argument to $ua->credentials. See [RT#31969].