diff --git a/ddclient.in b/ddclient.in index 2cbd994..cbd009a 100755 --- a/ddclient.in +++ b/ddclient.in @@ -4215,21 +4215,15 @@ 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) { - debug("HTTP headers are stripped."); - } else { - warning("Unexpected: no HTTP headers stripped!"); + my $body = ($reply =~ s/^.*?\r?\n\r?\n//sr); + my $response = eval { decode_json($body); }; + if (!$response) { + failed("failed to parse response: $@"); + next; } - my $response = decode_json($reply); if (!defined($response->{'code'}) || !defined($response->{'message'})) { - failed("Did not receive expected \"code\" and \"message\" keys in server response."); - failed("Response:"); - failed("%s", $response); + failed("Did not receive expected 'code' and 'message' keys in server response:\n%s", + $body); next; } my %codemeaning = (