Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
6188fad0
Commit
6188fad0
authored
Nov 09, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 515644: Provide ETag support for config.cgi
Patch by Frank Becker <Frank@Frank-Becker.de> r=mkanat, a=mkanat
parent
36d69066
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
5 deletions
+37
-5
config.cgi
config.cgi
+37
-5
No files found.
config.cgi
View file @
6188fad0
...
...
@@ -20,6 +20,7 @@
#
# Contributor(s): Terry Weissman <terry@mozilla.org>
# Myk Melez <myk@mozilla.org>
# Frank Becker <Frank@Frank-Becker.de>
################################################################################
# Script Initialization
...
...
@@ -36,6 +37,7 @@ use Bugzilla::Error;
use
Bugzilla::
Keyword
;
use
Bugzilla::
Status
;
use
Bugzilla::
Field
;
use
Digest::
MD5
qw(md5_base64)
;
my
$user
=
Bugzilla
->
login
(
LOGIN_OPTIONAL
);
my
$cgi
=
Bugzilla
->
cgi
;
...
...
@@ -110,11 +112,41 @@ sub display_data {
my
$format
=
$template
->
get_format
(
"config"
,
scalar
(
$cgi
->
param
(
'format'
)),
scalar
(
$cgi
->
param
(
'ctype'
))
||
"js"
);
# Return HTTP headers.
print
"Content-Type: $format->{'ctype'}\n\n"
;
# Generate the configuration file and return it to the user.
$template
->
process
(
$format
->
{
'template'
},
$vars
)
# Generate the configuration data.
my
$output
;
$template
->
process
(
$format
->
{
'template'
},
$vars
,
\
$output
)
||
ThrowTemplateError
(
$template
->
error
());
# Wide characters cause md5_base64() to die.
my
$digest_data
=
$output
;
utf8::
encode
(
$digest_data
)
if
utf8::
is_utf8
(
$digest_data
);
my
$digest
=
md5_base64
(
$digest_data
);
# ETag support.
my
$if_none_match
=
$cgi
->
http
(
'If-None-Match'
)
||
""
;
my
$found304
;
my
@if_none
=
split
(
/[\s,]+/
,
$if_none_match
);
foreach
my
$if_none
(
@if_none
)
{
# remove quotes from begin and end of the string
$if_none
=~
s/^\"//g
;
$if_none
=~
s/\"$//g
;
if
(
$if_none
eq
$digest
or
$if_none
eq
'*'
)
{
# leave the loop after the first match
$found304
=
$if_none
;
last
;
}
}
if
(
$found304
)
{
print
$cgi
->
header
(
-
type
=>
'text/html'
,
-
ETag
=>
$found304
,
-
status
=>
'304 Not Modified'
);
}
else
{
# Return HTTP headers.
print
$cgi
->
header
(
-
ETag
=>
$digest
,
-
type
=>
$format
->
{
'ctype'
});
print
$output
;
}
exit
;
}
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