aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2011-12-26 14:10:52 +0100
committerFrédéric Buclin <LpSolit@gmail.com>2011-12-26 14:10:52 +0100
commit37e65a3c81d24eed2154b08e0c86e4cb44e167d3 (patch)
tree3d2fa291dc014dd3a23efab773948c44c5a8d490 /config.cgi
parentBug 399080: Remove the 'usebugaliases' parameter (turned on permanently) (diff)
downloadbugzilla-37e65a3c81d24eed2154b08e0c86e4cb44e167d3.tar.gz
bugzilla-37e65a3c81d24eed2154b08e0c86e4cb44e167d3.tar.bz2
bugzilla-37e65a3c81d24eed2154b08e0c86e4cb44e167d3.zip
Bug 629326: Make it simpler to check ETags
r/a=LpSolit
Diffstat (limited to 'config.cgi')
-rwxr-xr-xconfig.cgi39
1 files changed, 9 insertions, 30 deletions
diff --git a/config.cgi b/config.cgi
index f83ffcdf3..fadc778b8 100755
--- a/config.cgi
+++ b/config.cgi
@@ -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;
}