From 6d7deac70d4110db765ef58b8f11a1d75f320a11 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 19 Oct 2023 15:26:08 +0200 Subject: [PATCH] pvesh: code cleanups for streamed response handling Signed-off-by: Thomas Lamprecht --- PVE/CLI/pvesh.pm | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/PVE/CLI/pvesh.pm b/PVE/CLI/pvesh.pm index 61b4464d..803553d9 100755 --- a/PVE/CLI/pvesh.pm +++ b/PVE/CLI/pvesh.pm @@ -289,18 +289,13 @@ my $handle_streamed_response = sub { my ($fh, $path, $encoding, $type) = $download->@{'fh', 'path', 'content-encoding', 'content-type'}; - die "{download} returned but neither fh nor path given\n" - if !defined($fh) && !defined($path); + die "{download} returned but neither fh nor path given\n" if !defined($fh) && !defined($path); - die "unknown 'content-encoding' $encoding\n" - if defined($encoding) && $encoding ne 'gzip'; - - die "unknown 'content-type' $type\n" - if defined($type) && $type !~ qw!^(text/plain)|(application/json)$!; + die "unknown 'content-encoding' $encoding\n" if defined($encoding) && $encoding ne 'gzip'; + die "unknown 'content-type' $type\n" if defined($type) && $type !~ qw!^(?:text/plain|application/json)$!; if (defined($path)) { - open($fh, '<', $path) - or die "open stream path '$path' for reading failed: $!\n"; + open($fh, '<', $path) or die "open stream path '$path' for reading failed - $!\n"; } local $/;