in reply to Re: Re: Unable to get LWP Basic Authentication to Work
in thread Unable to get LWP Basic Authentication to Work

You don't see the "Object Moved" message from your browser because there is also a redirect header in that response, and the browser follows that.

Have a closer look at how the LWP::UserAgent handleds request chains, especially in terms of examining what you get back as a response. The response object you were originally getting, for example, would tell you that you needed to provide authentication credentials, and also told you the "realm" for which it was expecting you to authenticate. Browsers manage this hand-shaking behind the scenes for you.

Generally, I would have expected LWP::UserAgent to have followed the redirect to the new location, but it may be that with the POST data it consciously doesn't do so (I don't know for certain on this point). Still, you can use the Location: header to determine the new URL, and send the same content-body to the new location. If you created an actual HTTP::Request object to pass to the useragent object (as opposed to creating a throw-away instance within the parameter list to $US->request()), you can re-assign the request's URL using the ->uri($new_uri) method as detailed in the manual page.

--rjray

  • Comment on Re: Re: Re: Unable to get LWP Basic Authentication to Work