(no subject)
Sidney Roberts (sidney_roberts@hotmail.com)
Fri, 05 Mar 1999 15:00:36 PST
Hello. I posted the following message to a usenet group, but I
thought maybe somebody on this mailing list could help as well. Thanks
in advance:
------------------------------------------------------------------
I have a list of url's and I need to check three things. First,
did I get a response back from the server. Second, was the file
found or not? Third (and this is important), was the response that
I got back binary or text data?
Right now, I'm doing it this way:
#--
for ($pic_count = 0; $pic_count < 100; $pic_count++)
{
$pic_url = $pic_array[$pic_count];
$agent = LWP::UserAgent->new();
print "TESTING: $pic_url";
$request = HTTP::Request->new('HEAD', $pic_url);
$response = $agent->request($request);
$result = $response->code;
if ($result != '200')
{
print " not found ($result).\n";
} else {
print " ", $result, "\n";
}
}
#---
There's a few problems with this, though. First, it's really
slow. I think it's because it's downloading the whole file (I'm
requesting binary files) before it gives a response or not. What
I'd like to do is just download the first 64 bytes or so and check
that data. Secondly, can I assume that 200 is the "everything was
cool" response? Also, how would I go about setting the timeout time
before it returns an error?
Thanks in advance for any help you can give.
--
Sidney Roberts
sidney_roberts@dejanews.com
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com