I have been trying to pull a text file that is on a password protected part
of a webserver. I am using the UserAgent object and calling the credentials
function to provide the information to authenticate and retrieve the file
but it doesn't seem to be working properly.
here is my code: (authentication data has been changed for security
purposes)
#!/usr/local/bin/perl
require LWP::UserAgent;
$ua = new LWP::UserAgent;
$netloc = "www.foo.com";
$realm = "Protected Area";
$user = "uname";
$pass = "passwd";
$ua->credentials($netloc, $realm, $user, $pass);
$request = new HTTP::Request('GET', 'http://www.foo.com/private/foo.txt');
$response = $ua->request($request);
print $response->content;
This is the response:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>401 Authorization Required</TITLE>
</HEAD><BODY>
<H1>Authorization Required</H1>
This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.<P>
</BODY></HTML>
I'm sure that the authentication data I am passing is correct. Any help
would be appreciated.
Ramon Rodriguez
Internet Developer
[EMAIL PROTECTED]
E-Commerce Solutions LLC (ECS)