Mike Blezien wrote:
> hello all,
>
> I'm working on a project, which uses the LWP::UserAgent module, and all is
> working fine untill we had to password protect a folder with a .htaccess file,
> on the remote server. Now we can't grab the file from the remote server, without
> the passing the proper access information.
>
> Script SniP;
>
> my $fileURL = "http://www.some_domain.com/folder/some_file_name";
> my $capture = undef;
> my $ua = new LWP::UserAgent;
> my $req = new HTTP::Request 'GET' => "$fileURL";
> my $res = $ua->request($req);
>
> if ($res->is_error()) { print qq~Unable to Grab file~; exit(); }
> if ($res->is_success()) { $capture = $res->content(); }
> if (defined($capture)) {
> # do some stuff here with the file content.
> }
What I usually code here - and what you may prefer - is
my $res = $ua->get ($fileURL);
die $res->status_line unless $res->is_success;
if ($capture = $res->content) {
:
}
> this script resides on a different server, grabs and processes various files
> from a remote server. as I say, it was working file until the "/folder" was
> password protected, now, naturally we can't unless we pass the access info in
> order to grab the files.. It seems to me that this can be done with the LWP
> modules, but I haven't been able to find the right method to do this... can this
> be done, if so, please direct me to the appropriate information or a sample code
> if possible.
It would be useful to know what error code the server was returning. I think it's
almost certain to be 500 - Internal Server Error rather than 401 - Unauthorized,
which would mean that it's the Web server that can't read the file to pass it back
to you. All you can do from an HTTP client is pass a server-enforced username
and password for a resource, which is independent of the user accounts on the
remote operating system.
This is equivalent to the 500 - Internal Server Error error that you get when a
CGI script hasn't been enabled for execution byt the server with chmod 755
or similar.
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]