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