Re: [PATCH] LWP::UserAgent add support for URI with embedded userinfo

"Philippe Bruhat (BooK)" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <20100324083709.GH7221@plop>
On Tue, Mar 23, 2010 at 09:15:47PM +0100, Gisle Aas wrote:
> On Tue, Mar 23, 2010 at 10:43, Philippe Bruhat (BooK) <[email protected]> wrote:
> > ---
> >  lib/LWP/UserAgent.pm |    1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/lib/LWP/UserAgent.pm b/lib/LWP/UserAgent.pm
> > index a54782c..7757126 100644
> > --- a/lib/LWP/UserAgent.pm
> > +++ b/lib/LWP/UserAgent.pm
> > @@ -572,6 +572,7 @@ sub get_basic_credentials
> >  {
> >     my($self, $realm, $uri, $proxy) = @_;
> >     return if $proxy;
> > +    return $uri->userinfo if $uri->can('userinfo') && $uri->userinfo;
> >     return $self->credentials($uri->host_port, $realm);
> >  }
> 
> The $uri->userinfo doesn't have the same return value signature as
> $ua->get_basic_credentials so I can't see how this would work.  Do you
> claim that this works for you?

Actually, I was looking into getting http://user:pass@url/ URL work
for WWW::Mechanize. Then I remembered WWW::Mechanize is a subclass
of LWP::UserAgent, so if there was a problem, I should be fixing it
in LWP::UA directly.

I was a bit too quick at trying to find the place to patch... And too
impatient to bother with testing. :-S

Apparently I was completely mistaken, since further testing with Mechanize
this morning shows that indeed it will already work with such URLs.

I may have been mislead by the fact the URL I was trying to reach was also
https and maybe Crypt::SSLeay wasn't installed with the perl I was using.

> LWP::Protocol::http already try to deal with embedded userinfo in its
> _fixup_header method.

Thanks! And sorry for the noise.

-- 
 Philippe Bruhat (BooK)

 The surest path to chaos is too much organization.
                                                 (Moral from Groo #4 (Image))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.