James Cloos <cloos@xxxxxxxxxxx> writes:
> I have some code that does:
>
> my $req = HTTP::Request->new(GET => "http://$foo/bar");
> my $res = $ua->request($req);
> push @good, $foo if ($res->is_success);
>
> in a loop.
>
> I tested that is_success did the right thing if the file bar was not
> in teh server's $SERVER_ROOT, and I presumed it would return false
> if $foo was not up.
>
> But in fact, $res->_rc is 200 when the remote box is down just like
> when the file bar exists.
>
> Tested on gentoo w/ latest ebuilds of perl and libwww, and freebsd
> 5.2.1 w/ their ports.
>
> Why does _rc == 200 when their was no reply from the server?
I've never seen that happen. Can you provide me with the full
$res->as_string output in this case. It might also be instructive to
strace the client as it runs to see what happens at the syscall level.
If you get a 200 response it must mean that the connection to the
server succeeded.
> I presume part of the problem is that it appears to be sending a HTTP
> 0.9 GET rather than a 1.0 GET. I don't see anything in the docs
> about forcing the latter. How is that done?
LWP always sends HTTP/1.1 GETs.
> Or should I do a HEAD instead of a GET, given that I'm only testing
> for the existence of the file and the network connection between the
> two boxen?
The HEAD might be cheaper, but not all servers implement it for all
resources.
Regards,
Gisle
|