]> git.proxmox.com Git - pve-http-server.git/commitdiff
acknowledge content-disposition header
authorDaniel Tschlatscher <d.tschlatscher@proxmox.com>
Wed, 7 Sep 2022 08:56:28 +0000 (10:56 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 29 Sep 2022 12:35:32 +0000 (14:35 +0200)
Acknowledging the Content-Disposition header makes it possible for the
backend to tell the browser whether a file should be downloaded,
rather than displayed inline, and what it's default name should be.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
src/PVE/APIServer/AnyEvent.pm

index 877a4e6eea96508badbf990bc3e1c39cacd95b4e..130727b41a11a6fffd5116c9c74701baf9a672d9 100644 (file)
@@ -426,6 +426,7 @@ sub send_file_start {
            if (ref($download) eq 'HASH') {
                $mime = $download->{'content-type'};
                my $encoding = $download->{'content-encoding'};
+               my $disposition = $download->{'content-disposition'};
 
                if ($download->{path} && $download->{stream} &&
                    $reqstate->{request}->header('PVEDisableProxy'))
@@ -438,6 +439,7 @@ sub send_file_start {
                        Content_Type => $mime,
                    );
                    $header->header('Content-Encoding' => $encoding) if defined($encoding);
+                   $header->header('Content-Disposition' => $disposition) if defined($disposition);
                    # we need some data so Content-Length gets set correctly and
                    # the proxy doesn't wait for more data - place a canary
                    my $resp = HTTP::Response->new(200, "OK", $header, "error canary");
@@ -456,6 +458,7 @@ sub send_file_start {
                if ($download->{stream}) {
                    my $header = HTTP::Headers->new(Content_Type => $mime);
                    $header->header('Content-Encoding' => $encoding) if defined($encoding);
+                   $header->header('Content-Disposition' => $disposition) if defined($disposition);
                    my $resp = HTTP::Response->new(200, "OK", $header);
                    $self->response($reqstate, $resp, undef, 1, 0, $fh);
                    return;