dnsexit2: Fix extraction and processing of JSON response body
This commit is contained in:
parent
86ec02a9b6
commit
7b95b379aa
1 changed files with 4 additions and 7 deletions
11
ddclient.in
11
ddclient.in
|
@ -4215,17 +4215,14 @@ sub nic_dnsexit2_update {
|
||||||
failed("Full reply\n%s", $reply) unless opt('verbose');
|
failed("Full reply\n%s", $reply) unless opt('verbose');
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
my $body = ($reply =~ s/^.*?\r?\n\r?\n//sr);
|
||||||
# Strip HTTP response headers
|
debug("body\n%s", $body);
|
||||||
(my $strip_status) = ($reply =~ s/^[\s\S]*?(?=\{"code":)//);
|
if ($body ne $reply) {
|
||||||
debug("strip_status");
|
|
||||||
debug("%s", $strip_status);
|
|
||||||
if ($strip_status) {
|
|
||||||
debug("HTTP headers are stripped.");
|
debug("HTTP headers are stripped.");
|
||||||
} else {
|
} else {
|
||||||
warning("Unexpected: no HTTP headers stripped!");
|
warning("Unexpected: no HTTP headers stripped!");
|
||||||
}
|
}
|
||||||
my $response = decode_json($reply);
|
my $response = decode_json($body);
|
||||||
if (!defined($response->{'code'}) || !defined($response->{'message'})) {
|
if (!defined($response->{'code'}) || !defined($response->{'message'})) {
|
||||||
failed("Did not receive expected \"code\" and \"message\" keys in server response.");
|
failed("Did not receive expected \"code\" and \"message\" keys in server response.");
|
||||||
failed("Response:");
|
failed("Response:");
|
||||||
|
|
Loading…
Reference in a new issue