in reply to Re: Re: WWW::Mechanize and basic authentication
in thread WWW::Mechanize and basic authentication

It doesn't work because the get and follow methods create a new HTTP::Request object every time.

req returns the HTTP::Request that was used in the last request, not the one that will be used in the next - so yes, a little late in the process :-)

Replies are listed 'Best First'.
Re: Re^3: WWW::Mechanize and basic authentication
by iguanodon (Priest) on Jan 29, 2003 at 15:49 UTC
    Well, that makes perfect sense. Thanks and ++ again, adrianh.

Re: Re^3: WWW::Mechanize and basic authentication
by petdance (Parson) on Jan 29, 2003 at 17:23 UTC
    Perhaps I should make the new HTTP::Request that gets created by follow() somehow inherit the credentials from the initial request?

    Or is this not a problem?

    xoxo,
    Andy
    --
    <megaphone> Throw down the gun and tiara and come out of the float! </megaphone>

      I don't think it it's a problem. Calling $agent->credentials() makes more sense than getting an HTTP::Request object and calling authorization_basic() on it, now that I understand how it works. An example in the docs would be good, though.

        As always, patches welcome!

        If you have sample code and an explanation, I'll add it to the docs for the distro. Either email me at andy@petdance.com or submit it at http://rt.cpan.org.

        Thanks,
        xoxo,
        Andy

      Perhaps I should make the new HTTP::Request that gets created by follow() somehow inherit the credentials from the initial request?

      Maybe have the option to specify the request object in the follow/get so you could do:

      $agent->follow($link, request => $agent->req)

      Then again, it's never been a problem for me. Maybe make the semantics of req a little more explicit in the docs?