]> git.proxmox.com Git - pve-manager.git/commitdiff
pvesh: code cleanups for streamed response handling
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 19 Oct 2023 13:26:08 +0000 (15:26 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 19 Oct 2023 13:26:08 +0000 (15:26 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/CLI/pvesh.pm

index 61b4464d63ea209a784581656d0d5d1c0b2ee7d4..803553d9fb9203256d28526ef83dd1acb89dcaf6 100755 (executable)
@@ -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 $/;