forked from Mirror/pve-network
api request helper: use builtin method to check success of requests
Avoid using a regex if we have a builtin function ready to use. Signed-off-by: Hannes Duerr <h.duerr@proxmox.com> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com> [TL: touch up commit message] Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
9829f51a48
commit
77671ba327
|
@ -273,10 +273,10 @@ sub api_request {
|
||||||
$ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00);
|
$ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00);
|
||||||
|
|
||||||
my $response = $ua->request($req);
|
my $response = $ua->request($req);
|
||||||
my $code = $response->code;
|
|
||||||
|
|
||||||
if ($code !~ /^2(\d+)$/) {
|
if (!$response->is_success) {
|
||||||
my $msg = $response->message || 'unknown';
|
my $msg = $response->message || 'unknown';
|
||||||
|
my $code = $response->code;
|
||||||
die "Invalid response from server: $code $msg\n";
|
die "Invalid response from server: $code $msg\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue