Hi folks,

I'm using LWP as part of another module, HTTP::WebTest, for testing my web 
apps. I am seeing an occassional error in my WebTest logs which, as best I 
can tell since I see no errors in my server logs, is the result of a 
timeout while trying to connect to the server. The error message reported 
by LWP is 
   "500 (Internal Server Error) Can't connect to www.yahoo.edu:80 (Bad 
    hostname 'www.yahoo.edu')"

This question seems like an FAQ but the only relevant post I could find in 
the  archives was from Doug Monroe on 14-Sep-2000.
  <http://www.mail-archive.com/[email protected]/msg01280.html>

He suggests that this kind of error should be reported as a 504 which 
makes more sense to me. Is there a historical reason or logical reason 
that I'm not understanding for reporting a connection failure as a 500 
response?

I've included a sample script at the end of my email to demonstrate this 
behavior. In fact, I tried both an invalid url as well as a valid url with 
my ethernet cable disconnected which should result in a timeout for which 
I don't think there is an official HTTP status code. Both tests resulted 
in the same response.

Thanks,
William

---------
#!/usr/bin/perl -Tw
use strict;

#
# TESTING HTTP::RESPONSE
#
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

my $url = 'http://www.yahoo.edu'; # invalid url
#my $url = 'http://www.yahoo.com'; # valid url (unplug/disable network to 
test)
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new(GET => $url);
my $response = $ua->request($request);
if ($response->is_success) {
 print $response->content;
} else {
 print $response->as_string;
}
------------
-- 
 Lead Developer
 Knowmad Services Inc. || Internet Applications & Database Integration
 http://www.knowmad.com
 

Reply via email to