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
37e65a3c
Commit
37e65a3c
authored
Dec 26, 2011
by
Max Kanat-Alexander
Committed by
Frédéric Buclin
Dec 26, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 629326: Make it simpler to check ETags
r/a=LpSolit
parent
6d02055d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
30 deletions
+29
-30
CGI.pm
Bugzilla/CGI.pm
+20
-0
config.cgi
config.cgi
+9
-30
No files found.
Bugzilla/CGI.pm
View file @
37e65a3c
...
...
@@ -214,6 +214,26 @@ sub clean_search_url {
}
}
sub
check_etag
{
my
(
$self
,
$valid_etag
)
=
@_
;
# ETag support.
my
$if_none_match
=
$self
->
http
(
'If-None-Match'
);
return
if
!
$if_none_match
;
my
@if_none
=
split
(
/[\s,]+/
,
$if_none_match
);
foreach
my
$possible_etag
(
@if_none
)
{
# remove quotes from begin and end of the string
$possible_etag
=~
s/^\"//g
;
$possible_etag
=~
s/\"$//g
;
if
(
$possible_etag
eq
$valid_etag
or
$possible_etag
eq
'*'
)
{
print
$self
->
header
(
-
ETag
=>
$possible_etag
,
-
status
=>
'304 Not Modified'
);
exit
;
}
}
}
# Overwrite to ensure nph doesn't get set, and unset HEADERS_ONCE
sub
multipart_init
{
my
$self
=
shift
;
...
...
config.cgi
View file @
37e65a3c
...
...
@@ -44,15 +44,16 @@ use Digest::MD5 qw(md5_base64);
my
$user
=
Bugzilla
->
login
(
LOGIN_OPTIONAL
);
my
$cgi
=
Bugzilla
->
cgi
;
# Get data from the shadow DB as they don't change very often.
Bugzilla
->
switch_to_shadow_db
;
# If the 'requirelogin' parameter is on and the user is not
# authenticated, return empty fields.
if
(
Bugzilla
->
params
->
{
'requirelogin'
}
&&
!
$user
->
id
)
{
display_data
();
exit
;
}
# Get data from the shadow DB as they don't change very often.
Bugzilla
->
switch_to_shadow_db
;
# Pass a bunch of Bugzilla configuration to the templates.
my
$vars
=
{};
$vars
->
{
'priority'
}
=
get_legal_field_values
(
'priority'
);
...
...
@@ -136,31 +137,9 @@ sub display_data {
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
;
$cgi
->
check_etag
(
$digest
);
print
$cgi
->
header
(
-
ETag
=>
$digest
,
-
type
=>
$format
->
{
'ctype'
});
print
$output
;
}
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