mirror of
https://git.proxmox.com/git/pve-http-server
synced 2025-05-01 17:03:51 +00:00
download-stream: allow the api call to set the content-encoding
this is useful if we want to pipe the output of a program e.g. through gzip Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
7599c47894
commit
127dbe7c7d
@ -413,6 +413,7 @@ sub send_file_start {
|
|||||||
|
|
||||||
if (ref($download) eq 'HASH') {
|
if (ref($download) eq 'HASH') {
|
||||||
$mime = $download->{'content-type'};
|
$mime = $download->{'content-type'};
|
||||||
|
my $encoding = $download->{'content-encoding'};
|
||||||
|
|
||||||
if ($download->{path} && $download->{stream} &&
|
if ($download->{path} && $download->{stream} &&
|
||||||
$reqstate->{request}->header('PVEDisableProxy'))
|
$reqstate->{request}->header('PVEDisableProxy'))
|
||||||
@ -424,6 +425,7 @@ sub send_file_start {
|
|||||||
pvestreamfile => $download->{path},
|
pvestreamfile => $download->{path},
|
||||||
Content_Type => $mime,
|
Content_Type => $mime,
|
||||||
);
|
);
|
||||||
|
$header->header('Content-Encoding' => $encoding) if defined($encoding);
|
||||||
# we need some data so Content-Length gets set correctly and
|
# we need some data so Content-Length gets set correctly and
|
||||||
# the proxy doesn't wait for more data - place a canary
|
# the proxy doesn't wait for more data - place a canary
|
||||||
my $resp = HTTP::Response->new(200, "OK", $header, "error canary");
|
my $resp = HTTP::Response->new(200, "OK", $header, "error canary");
|
||||||
@ -441,6 +443,7 @@ sub send_file_start {
|
|||||||
|
|
||||||
if ($download->{stream}) {
|
if ($download->{stream}) {
|
||||||
my $header = HTTP::Headers->new(Content_Type => $mime);
|
my $header = HTTP::Headers->new(Content_Type => $mime);
|
||||||
|
$header->header('Content-Encoding' => $encoding) if defined($encoding);
|
||||||
my $resp = HTTP::Response->new(200, "OK", $header);
|
my $resp = HTTP::Response->new(200, "OK", $header);
|
||||||
$self->response($reqstate, $resp, undef, 1, 0, $fh);
|
$self->response($reqstate, $resp, undef, 1, 0, $fh);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user