Commit e4f2a5c5 authored by Alexandre Derumier's avatar Alexandre Derumier Committed by Dietmar Maurer

avoid gzip http response for png & gif

Signed-off-by: 's avatarAlexandre Derumier <aderumier@odiso.com>
parent 957f0862
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment