header_ok: Refactor for readability
This commit is contained in:
parent
adbac91be7
commit
7fe7fd0e18
1 changed files with 14 additions and 17 deletions
31
ddclient.in
31
ddclient.in
|
@ -3775,24 +3775,21 @@ sub nic_updateable {
|
||||||
sub header_ok {
|
sub header_ok {
|
||||||
my ($host, $line) = @_;
|
my ($host, $line) = @_;
|
||||||
$line =~ s/\r?\n.*//s;
|
$line =~ s/\r?\n.*//s;
|
||||||
my $ok = 0;
|
# TODO: What is this leading /s*/? Is it a typo of /\s*/?
|
||||||
|
my ($result) = ($line =~ qr%^s*HTTP/.*\s+(\d+)%i);
|
||||||
if ($line =~ m%^s*HTTP/.*\s+(\d+)%i) {
|
if (!defined($result)) {
|
||||||
my $result = $1;
|
failed('updating %s: unexpected HTTP response: %s', $host, $line);
|
||||||
|
return 0;
|
||||||
if ($result =~ m/^2\d\d$/) {
|
} elsif ($result eq '401') {
|
||||||
$ok = 1;
|
failed("updating %s: authentication failed (%s)", $host, $line);
|
||||||
|
return 0;
|
||||||
} elsif ($result eq '401') {
|
} elsif ($result eq '403') {
|
||||||
failed("updating %s: authentication failed (%s)", $host, $line);
|
failed("updating %s: not authorized (%s)", $host, $line);
|
||||||
} elsif ($result eq '403') {
|
return 0;
|
||||||
failed("updating %s: not authorized (%s)", $host, $line);
|
} elsif ($result !~ qr/^2\d\d$/) {
|
||||||
}
|
return 0;
|
||||||
|
|
||||||
} else {
|
|
||||||
failed("updating %s: unexpected line (%s)", $host, $line);
|
|
||||||
}
|
}
|
||||||
return $ok;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue