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:
How to get correct response through proxy?

 



spring.z
Deleted

Nov 12, 2000, 6:13 PM

Post #1 of 1 (311 views)
How to get correct response through proxy? Can't Post

I use LWP::UserAgent to validate the URL, I am using a proxy server. While I test a clearly error URL, I still get a 200 status code, but with a "Socket error:Host name lookup for 'www.china.ccom' failed " error message.
My purpose is to return a code indicate it was a invalid URL.
Wish your help! TIA!

#!c:/perl/bin
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->env_proxy; # initialize from environment variables
my $req = new HTTP::Request Get => 'http://www.china.ccom/'; # the URL 'http://www.china.ccom/' is not valid
print "Content-type: text/html\n\n";

my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print "<p>The URL is valid!</p>\n";
print $res->content;
} else {
print "<p>The URL is invalid!</p>\n";
print $res->content;
}

 
 


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

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