Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
e4f2a5c5
Commit
e4f2a5c5
authored
Jun 10, 2013
by
Alexandre Derumier
Committed by
Dietmar Maurer
Jun 11, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid gzip http response for png & gif
Signed-off-by:
Alexandre Derumier
<
aderumier@odiso.com
>
parent
957f0862
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
HTTPServer.pm
PVE/HTTPServer.pm
+6
-3
REST.pm
PVE/REST.pm
+3
-3
No files found.
PVE/HTTPServer.pm
View file @
e4f2a5c5
...
@@ -264,14 +264,17 @@ sub send_file_start {
...
@@ -264,14 +264,17 @@ sub send_file_start {
die
"
got short file
\n
"
if
!
defined
(
$len
)
||
$len
!=
$stat
->
size
;
die
"
got short file
\n
"
if
!
defined
(
$len
)
||
$len
!=
$stat
->
size
;
my
$ct
;
my
$ct
;
my
$nocomp
;
if
(
$filename
=~
m/\.css$/
)
{
if
(
$filename
=~
m/\.css$/
)
{
$ct
=
'
text/css
';
$ct
=
'
text/css
';
}
elsif
(
$filename
=~
m/\.js$/
)
{
}
elsif
(
$filename
=~
m/\.js$/
)
{
$ct
=
'
application/javascript
';
$ct
=
'
application/javascript
';
}
elsif
(
$filename
=~
m/\.png$/
)
{
}
elsif
(
$filename
=~
m/\.png$/
)
{
$ct
=
'
image/png
';
$ct
=
'
image/png
';
$nocomp
=
1
;
}
elsif
(
$filename
=~
m/\.gif$/
)
{
}
elsif
(
$filename
=~
m/\.gif$/
)
{
$ct
=
'
image/gif
';
$ct
=
'
image/gif
';
$nocomp
=
1
;
}
elsif
(
$filename
=~
m/\.jar$/
)
{
}
elsif
(
$filename
=~
m/\.jar$/
)
{
$ct
=
'
application/java-archive
';
$ct
=
'
application/java-archive
';
}
else
{
}
else
{
...
@@ -280,7 +283,7 @@ sub send_file_start {
...
@@ -280,7 +283,7 @@ sub send_file_start {
my
$header
=
HTTP::
Headers
->
new
(
Content_Type
=>
$ct
);
my
$header
=
HTTP::
Headers
->
new
(
Content_Type
=>
$ct
);
my
$resp
=
HTTP::
Response
->
new
(
200
,
"
OK
",
$header
,
$data
);
my
$resp
=
HTTP::
Response
->
new
(
200
,
"
OK
",
$header
,
$data
);
$self
->
response
(
$reqstate
,
$resp
,
$mtime
);
$self
->
response
(
$reqstate
,
$resp
,
$mtime
,
$nocomp
);
};
};
if
(
my
$err
=
$@
)
{
if
(
my
$err
=
$@
)
{
$self
->
error
(
$reqstate
,
501
,
$err
);
$self
->
error
(
$reqstate
,
501
,
$err
);
...
@@ -459,12 +462,12 @@ sub handle_api2_request {
...
@@ -459,12 +462,12 @@ sub handle_api2_request {
}
}
PVE::REST::
prepare_response_data
(
$format
,
$res
);
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
});
my
$resp
=
HTTP::
Response
->
new
(
$res
->
{
status
},
$res
->
{
message
});
$resp
->
header
("
Content-Type
"
=>
$ct
);
$resp
->
header
("
Content-Type
"
=>
$ct
);
$resp
->
content
(
$raw
);
$resp
->
content
(
$raw
);
$self
->
response
(
$reqstate
,
$resp
);
$self
->
response
(
$reqstate
,
$resp
,
$nocomp
);
};
};
if
(
my
$err
=
$@
)
{
if
(
my
$err
=
$@
)
{
$self
->
error
(
$reqstate
,
501
,
$err
);
$self
->
error
(
$reqstate
,
501
,
$err
);
...
...
PVE/REST.pm
View file @
e4f2a5c5
...
@@ -49,7 +49,7 @@ sub format_response_data {
...
@@ -49,7 +49,7 @@ sub format_response_data {
my
$data
=
$res
->
{
data
};
my
$data
=
$res
->
{
data
};
my
$info
=
$res
->
{
info
};
my
$info
=
$res
->
{
info
};
my
(
$ct
,
$raw
);
my
(
$ct
,
$raw
,
$nocomp
);
if
(
$format
eq
'
json
')
{
if
(
$format
eq
'
json
')
{
$ct
=
'
application/json;charset=UTF-8
';
$ct
=
'
application/json;charset=UTF-8
';
...
@@ -92,7 +92,7 @@ sub format_response_data {
...
@@ -92,7 +92,7 @@ sub format_response_data {
}
elsif
(
$format
eq
'
png
')
{
}
elsif
(
$format
eq
'
png
')
{
$ct
=
'
image/png
';
$ct
=
'
image/png
';
$nocomp
=
1
;
# fixme: better to revove that whole png thing ?
# fixme: better to revove that whole png thing ?
my
$filename
;
my
$filename
;
...
@@ -116,7 +116,7 @@ sub format_response_data {
...
@@ -116,7 +116,7 @@ sub format_response_data {
$raw
=
to_json
(
$data
,
{
utf8
=>
1
,
allow_nonref
=>
1
,
pretty
=>
1
});
$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
{
sub
prepare_response_data
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment