]> git.proxmox.com Git - pmg-api.git/commitdiff
HTTPServer: extend download functionality
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 10 Oct 2019 09:21:52 +0000 (11:21 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Oct 2019 13:22:05 +0000 (15:22 +0200)
allow object as return value for 'download' api calls
this way, we can give additional information for download apis
(like the content-type and if it should be deleted after)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/PMG/HTTPServer.pm

index 6997dd5cc704da27b382b2b5dab169a1bd0360c3..8c29059cd0606953090f31db1587ce77a5214f95 100755 (executable)
@@ -162,9 +162,13 @@ sub rest_handler {
        };
 
        if ($info->{download}) {
-           die "download methods should have return type 'string' - internal error"
-               if ($info->{returns}->{type} ne 'string');
-           $resp->{download} = $result;
+           my $type =  $info->{returns}->{type};
+           if ($type eq 'string' || $type eq 'object') {
+               $resp->{download} = $result;
+           } else {
+               die "API calls which trigger downloads need to have return type 'string' or 'object' - internal error"
+           }
+
        } else {
            $resp->{data} = $result;
        }