dnsexit2: Fix extraction and processing of JSON response body

This commit is contained in:
Richard Hansen 2024-05-30 17:37:59 -04:00
parent 86ec02a9b6
commit 7b95b379aa

View file

@ -4215,17 +4215,14 @@ sub nic_dnsexit2_update {
failed("Full reply\n%s", $reply) unless opt('verbose');
next;
}
# Strip HTTP response headers
(my $strip_status) = ($reply =~ s/^[\s\S]*?(?=\{"code":)//);
debug("strip_status");
debug("%s", $strip_status);
if ($strip_status) {
my $body = ($reply =~ s/^.*?\r?\n\r?\n//sr);
debug("body\n%s", $body);
if ($body ne $reply) {
debug("HTTP headers are stripped.");
} else {
warning("Unexpected: no HTTP headers stripped!");
}
my $response = decode_json($reply);
my $response = decode_json($body);
if (!defined($response->{'code'}) || !defined($response->{'message'})) {
failed("Did not receive expected \"code\" and \"message\" keys in server response.");
failed("Response:");