Steve Sheng a écrit :
pages. Some of them are not available either due to bad hostname or time out, or internal server error. My question is how to distinguish them,

my $resp = $ua->get($url); then check the $resp->status_line. Example values:

500 Can't connect to www...com:80 (Bad hostname 'www...com')
500 Can't connect to ...com:80 (connect: timeout)

for example I want to know how many of my requests failed because the uri was incorrect.

If you want to search for HTTP 404 Errors:

my $code = $resp->code();
then check $code value. Ex 400<=$code<=499 (man HTTP::Response)
or if ($error == RC_NOT_FOUND)... (man HTTP::Status)
or if (is_client_error($code))...

It seems to me that the LWP will simply return code 500 for all of them.

5xx HTTP code means 'Server error'. It seems LWP uses '500' when it cant reach the host. But whole status line is more verbose, if you need more information.

Ch.

Reply via email to