|
Posted by earwigtc on February 9, 2007, 11:39 am
Please log in for more thread options
I like it. I'm saving info (such as headers_as_string) of the request
object for debugging. I see $mech->response, but is there a way to
reference the request object? Never had to do it with just a
LWP::UserAgent object. Aside from that, I can rework using
WWW::Mechanize just fine.
I would still be interested in a working digest authentication example
with LWP directly, if anyone has one.
Earwig
> On Thu, 08 Feb 2007 10:50:08 -0800, earwigtc wrote:
> > Hi all. I must be missing something here. Is LWP supposed to
> > automatically deal with digest authentication? I run the following
> > code (used often with basic auth) against a server requiring digest,
> > and continue to get 401s:
>
> > my $ua = new LWP::UserAgent;
> > my $h = HTTP::Headers->new();
> > $h->authorization_basic('user','password');
> > my $req = HTTP::Request->new('GET', 'http://the.website.com',
> > $h);
> > my $res = $ua->request($req);
>
> I don't know what your problem is here or whether my suggestion will make
> any difference, but I will point out that the new credentials() method I
> added to WWW::Mechanize (1.20 and later) would make your code considerably
> simpler:
>
> my $mech = WWW::Mechanize->new;
> $mech->credentials('user', 'password');
> $mech->get('https://the.website.com/');
>
> > A sniff shows only one attempt to login, and no reaction to the fact
> > that the server returned a WWW-Authenticate header with the real,
> > nonce, etc. Do I need to call requests a different way to get the
> > auto-magical behavior? I'm using htis format because of other needs
> > (custom headers later).
>
> You would be able to do this with $mech->add_header.
>
> > Since I can't find any discussion or example of digest instead of
> > basic, I figured it should work. Or do I need to do all the digest
> > legwork myself?
>
> --
> Peter Scotthttp://www.perlmedic.com/http://www.perldebugged.com/
|