mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-03 21:03:52 +00:00
avoid gzip http response for png & gif
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
c7c42353a6
commit
0ebf2fa8d9
@ -264,14 +264,17 @@ sub send_file_start {
|
||||
die "got short file\n" if !defined($len) || $len != $stat->size;
|
||||
|
||||
my $ct;
|
||||
my $nocomp;
|
||||
if ($filename =~ m/\.css$/) {
|
||||
$ct = 'text/css';
|
||||
} elsif ($filename =~ m/\.js$/) {
|
||||
$ct = 'application/javascript';
|
||||
} elsif ($filename =~ m/\.png$/) {
|
||||
$ct = 'image/png';
|
||||
$nocomp = 1;
|
||||
} elsif ($filename =~ m/\.gif$/) {
|
||||
$ct = 'image/gif';
|
||||
$nocomp = 1;
|
||||
} elsif ($filename =~ m/\.jar$/) {
|
||||
$ct = 'application/java-archive';
|
||||
} else {
|
||||
@ -280,7 +283,7 @@ sub send_file_start {
|
||||
|
||||
my $header = HTTP::Headers->new(Content_Type => $ct);
|
||||
my $resp = HTTP::Response->new(200, "OK", $header, $data);
|
||||
$self->response($reqstate, $resp, $mtime);
|
||||
$self->response($reqstate, $resp, $mtime, $nocomp);
|
||||
};
|
||||
if (my $err = $@) {
|
||||
$self->error($reqstate, 501, $err);
|
||||
@ -459,12 +462,12 @@ sub handle_api2_request {
|
||||
}
|
||||
|
||||
PVE::REST::prepare_response_data($format, $res);
|
||||
my ($raw, $ct) = PVE::REST::format_response_data($format, $res, $path);
|
||||
my ($raw, $ct, $nocomp) = PVE::REST::format_response_data($format, $res, $path);
|
||||
|
||||
my $resp = HTTP::Response->new($res->{status}, $res->{message});
|
||||
$resp->header("Content-Type" => $ct);
|
||||
$resp->content($raw);
|
||||
$self->response($reqstate, $resp);
|
||||
$self->response($reqstate, $resp, $nocomp);
|
||||
};
|
||||
if (my $err = $@) {
|
||||
$self->error($reqstate, 501, $err);
|
||||
|
@ -49,7 +49,7 @@ sub format_response_data {
|
||||
my $data = $res->{data};
|
||||
my $info = $res->{info};
|
||||
|
||||
my ($ct, $raw);
|
||||
my ($ct, $raw, $nocomp);
|
||||
|
||||
if ($format eq 'json') {
|
||||
$ct = 'application/json;charset=UTF-8';
|
||||
@ -92,7 +92,7 @@ sub format_response_data {
|
||||
|
||||
} elsif ($format eq 'png') {
|
||||
$ct = 'image/png';
|
||||
|
||||
$nocomp = 1;
|
||||
# fixme: better to revove that whole png thing ?
|
||||
|
||||
my $filename;
|
||||
@ -116,7 +116,7 @@ sub format_response_data {
|
||||
$raw = to_json($data, {utf8 => 1, allow_nonref => 1, pretty => 1});
|
||||
}
|
||||
|
||||
return wantarray ? ($raw, $ct) : $raw;
|
||||
return wantarray ? ($raw, $ct, $nocomp) : $raw;
|
||||
}
|
||||
|
||||
sub prepare_response_data {
|
||||
|
Loading…
Reference in New Issue
Block a user