From 37e65a3c81d24eed2154b08e0c86e4cb44e167d3 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Mon, 26 Dec 2011 14:10:52 +0100 Subject: Bug 629326: Make it simpler to check ETags r/a=LpSolit --- Bugzilla/CGI.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Bugzilla') diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 9d8a1c48f..e1e6af6ae 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -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; -- cgit v1.2.3-24-g4f1b