mirror of
https://git.proxmox.com/git/pve-http-server
synced 2025-05-01 17:03:51 +00:00
handler: remove support for directly returned download info
this was only used by PMG's HttpServer and for non-API file responses. all of those got dropped there in favour of always returning an object like { data => { download => { [download info here] }, [..], }, [..], } in case of PMG, or passing in a download hash in case of APIServer internal calls. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> (cherry picked from commit fa82664f03ce97a367dbc39899f60d2b9fdb2d2d)
This commit is contained in:
parent
67b08d684c
commit
9134b2c972
@ -423,7 +423,9 @@ sub send_file_start {
|
||||
my $nocomp;
|
||||
my $mime;
|
||||
|
||||
if (ref($download) eq 'HASH') {
|
||||
die "invalid download information passed: '$download'\n"
|
||||
if ref($download) ne 'HASH';
|
||||
|
||||
$mime = $download->{'content-type'};
|
||||
my $encoding = $download->{'content-encoding'};
|
||||
my $disposition = $download->{'content-disposition'};
|
||||
@ -462,12 +464,8 @@ sub send_file_start {
|
||||
my $resp = HTTP::Response->new(200, "OK", $header);
|
||||
$self->response($reqstate, $resp, undef, 1, 0, $fh);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
my $filename = $download;
|
||||
$fh = IO::File->new($filename, '<') ||
|
||||
die "unable to open file '$filename' - $!\n";
|
||||
|
||||
} elsif (!$mime) {
|
||||
my $filename = $download->{path};
|
||||
my ($ext) = $filename =~ m/\.([^.]*)$/;
|
||||
my $ext_info = $file_extension_info->{$ext};
|
||||
|
||||
@ -959,8 +957,8 @@ sub handle_api2_request {
|
||||
$delay = 0 if $delay < 0;
|
||||
}
|
||||
|
||||
my $download = $res->{download};
|
||||
$download //= $res->{data}->{download}
|
||||
my $download;
|
||||
$download = $res->{data}->{download}
|
||||
if defined($res->{data}) && ref($res->{data}) eq 'HASH';
|
||||
if (defined($download)) {
|
||||
if ($res->{info}->{download}) {
|
||||
@ -1152,7 +1150,7 @@ sub handle_request {
|
||||
if (my $filename = $handler->{file}) {
|
||||
my $fh = IO::File->new($filename) ||
|
||||
die "unable to open file '$filename' - $!\n";
|
||||
send_file_start($self, $reqstate, $filename);
|
||||
send_file_start($self, $reqstate, { path => $filename });
|
||||
} else {
|
||||
die "internal error - no handler";
|
||||
}
|
||||
@ -1170,7 +1168,7 @@ sub handle_request {
|
||||
my $filename = "$dir$file";
|
||||
my $fh = IO::File->new($filename) ||
|
||||
die "unable to open file '$filename' - $!\n";
|
||||
send_file_start($self, $reqstate, $filename);
|
||||
send_file_start($self, $reqstate, { path => $filename });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user