forked from Mirror/pve-network
sdn: code & indentation cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
d7d1181ed5
commit
9f4525c350
|
@ -269,7 +269,7 @@ sub api_request {
|
||||||
if ($proxy) {
|
if ($proxy) {
|
||||||
$ua->proxy(['http', 'https'], $proxy);
|
$ua->proxy(['http', 'https'], $proxy);
|
||||||
} else {
|
} else {
|
||||||
$ua->env_proxy;
|
$ua->env_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00);
|
$ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00);
|
||||||
|
@ -278,8 +278,8 @@ sub api_request {
|
||||||
my $code = $response->code;
|
my $code = $response->code;
|
||||||
|
|
||||||
if ($code !~ /^2(\d+)$/) {
|
if ($code !~ /^2(\d+)$/) {
|
||||||
my $msg = $response->message || 'unknown';
|
my $msg = $response->message || 'unknown';
|
||||||
die "Invalid response from server: $code $msg\n";
|
die "Invalid response from server: $code $msg\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $raw = '';
|
my $raw = '';
|
||||||
|
@ -288,16 +288,12 @@ sub api_request {
|
||||||
} else {
|
} else {
|
||||||
$raw = $response->content;
|
$raw = $response->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
return if $raw eq '';
|
return if $raw eq '';
|
||||||
|
|
||||||
my $json = '';
|
my $res = eval { from_json($raw) };
|
||||||
eval {
|
|
||||||
$json = from_json($raw);
|
|
||||||
};
|
|
||||||
die "api response is not a json" if $@;
|
die "api response is not a json" if $@;
|
||||||
|
|
||||||
return $json;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in a new issue