diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2020-04-30 14:10:59 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2020-04-30 14:10:59 -0700 |
commit | 29f83dc5cca5e06718842753c229bff6f417e244 (patch) | |
tree | bd16a9694e8c08d81c2edaf9a19dda3ac9a3677a | |
parent | probe-mirmon: make even less stderr (diff) | |
download | gentoo-mirrorstats-29f83dc5cca5e06718842753c229bff6f417e244.tar.gz gentoo-mirrorstats-29f83dc5cca5e06718842753c229bff6f417e244.tar.bz2 gentoo-mirrorstats-29f83dc5cca5e06718842753c229bff6f417e244.zip |
probe-mirmon: handle curl error conditions better
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rwxr-xr-x | probe-mirmon | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/probe-mirmon b/probe-mirmon index 1e10ef1..5d99cda 100755 --- a/probe-mirmon +++ b/probe-mirmon @@ -53,19 +53,16 @@ sub handle_libcurl { my $retcode = $curl->perform; # Looking at the results... - if ($retcode == 0) { - #print("Transfer went ok\n"); - my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE); - # judge result and next action based on $response_code - #print("Received response: $response_code $response_body\n"); - chomp $response_body; - #print("s='$response_body'\n"); - print(munge_date($response_body), "\n"); - } else { - # Error code, type of error, error message - #print("An error happened: $retcode ".$curl->strerror($retcode)." ".$curl->errbuf."\n"); - exit 800; - } + exit 800 unless ($retcode == 0); + + my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE); + exit 801 unless ($response_code == 200) + exit 802 unless defined($response_body); + chomp $response_body; + print(munge_date($response_body), "\n"); + + exit 0; + #print("An error happened: $retcode ".$curl->strerror($retcode)." ".$curl->errbuf."\n"); } |