The following code has no effect. The server always responds 403 errors.
$mech->credentials($username, $password);
$mech->get($url);
The FAQ suggests to run the following code:
my @args = (
Authorization => "Basic " .
MIME::Base64::encode( $username . ':' . $password )
);
$agent->credentials( $host, "foo", $username, $password );
$agent->get( $url, @args );
This fragment works as expected.
According to the documentation in WWW::Mechanize the two chunks should be equivalent.
I found that the following code has the same effect as the second chunk:
my @args = (
Authorization => "Basic " .
MIME::Base64::encode( $username . ':' . $password )
);
$agent->get( $url, @args );
However, if I rephrase the code to the following fragment it will always fails.
$agent->credentials( $host, "foo", $username, $password );
$agent->get( $url );
This behaviour leads me to the conclusion that the credentials() function is non-functional.
I focused into the code and found that accessor function get_basic_credentials() is never called during the request process. Consequently, any global or host related credentials will never appear in the request headers.
This might be a problem of the underlying LWP::UA.
cpgl...@gmail.com reported on May 12, 2011
Details
Imported from Google Code issue 207 via archive