From 460ae51fc0e70dd2d7fcef4bdb92308269327f1d Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Fri, 9 Aug 2013 13:55:53 -0400 Subject: Bug 903514 - Backport upstream bug 569177 for etag support to bmo/4.2 --- config.cgi | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'config.cgi') diff --git a/config.cgi b/config.cgi index 963224638..fcc5d82ed 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,13 @@ 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, + if ($cgi->check_etag($digest)) { + print $cgi->header(-ETag => $digest, -status => '304 Not Modified'); + exit; } - else { - # Return HTTP headers. - print $cgi->header (-ETag => $digest, - -type => $format->{'ctype'}); - print $output; - } - exit; + + print $cgi->header (-ETag => $digest, + -type => $format->{'ctype'}); + print $output; } -- cgit v1.2.3-24-g4f1b