CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Need help on LWP::UserAgent module!

 



spring.z
Deleted

Nov 13, 2000, 3:41 AM

Post #1 of 1 (414 views)
Need help on LWP::UserAgent module! Can't Post

I use the following to tell the validation of a url.
Why I get 500 error, while the URL can be open correctly?
Any suggestion on validate a URL?


Following is my code:
#!c:/perl/bin -w
use LWP::UserAgent;

print "Content-type: text/html\n\n";

$ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(Get => "http://www.mytophome.com/cgi-bin/gzhome/public/index.jsp");

my $res = $ua->request($req);

# Check the outcome of the response
if ($res->is_success) {
print "<html><head><title>URL Test</title></head>\n";
print "<body>\n";
print "<h2>Congratuation!</h2><hr>\n";
print "<p>The URL '$url' is valid!</p>\n";
print "<p align=center><a href='javascript:window.close()'>Close Window</a></p>\n";
print "</body></html>\n";
} else {
print "<html><head><title>URL Test</title></head>\n";
print "<body>\n";
print "<h2>Not so luck today!</h2><hr>\n";
print "<p>The URL 'url' is invalid!</p>\n";
print "The error code is :";
print $res->code;
print "<br>\nThe error message is :";
print $res->message;
print "<br>\nThe error content is :";
print $res->content;
print "<p align=center><a href='javascript:window.close()'>Close Window</a></p>\n";
print "</body></html>\n";
}

Please note that the URL http://www.mytophome.com/cgi-bin/gzhome/public/index.jsp can be visited finely.
Wish your help!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives