Gossamer Forum
Home : General : Perl Programming :

URL Verification Problems

Quote Reply
URL Verification Problems
Hello,

I am trying to verify that URL's exist using LWP::UserAgent and HTTP::Request, but I am running into some problems.

It appears that if Directory Indexing is disabled, the response will not be successful and the URL verification will fail. Here is the code I am using:

use LWP::UserAgent;
use HTTP::Request;

$tmpl_image_url .= "$image_url/$template";
$ua = LWP::UserAgent->new;
$request = HTTP::Request->new(GET => "$tmpl_image_url");
$response = $ua->request($request);
unless ($response->is_success) {
$status .= qq~
...fail...

} else {
$status .= qq~
...pass...

}

This works on a server where I have Directory Indexing allowed, but not on a server where it is disabled. Any suggestions on a work-around or another way to verify if a URL/Link exists?

Thanks,

Eric
Quote Reply
Re: [emartin] URL Verification Problems In reply to
Got it figured out...

Changed it to:

$ua = LWP::UserAgent->new;
$request = HTTP::Request->new(GET => "$tmpl_image_url");
$response = $ua->request($request);
unless ($response->code != 404) {
...fail...

} else {
...pass...

}