From 50e47601c32562d7b9e698307f3d28e35729613a Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Thu, 29 Nov 2012 11:57:55 +0000 Subject: [PATCH] ETag stuff must respect the cacheable parameter git-svn-id: https://svn.fhem.de/fhem/trunk@2220 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/01_FHEMWEB.pm | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 82551b7ae..eee10f0dd 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -1245,21 +1245,25 @@ FW_returnFileAsStream($$$$$) { my ($path, $suffix, $type, $doEsc, $cacheable) = @_; - #Check for If-None-Match header (ETag) - my @if_none_match_lines = grep /If-None-Match/, @FW_httpheader; - my $if_none_match = undef; - if(@if_none_match_lines) { - $if_none_match = $if_none_match_lines[0]; - $if_none_match =~ s/If-None-Match: \"(.*)\"/$1/; - } - + my $etag; my $c = $FW_chash->{CD}; - my $etag = (stat($path))[9]; #mtime - if(defined($etag) and defined($if_none_match) and $etag eq $if_none_match) { - print $c "HTTP/1.1 304 Not Modified\r\n", - $FW_headercors, "\r\n"; - return -1; + if($cacheable) { + #Check for If-None-Match header (ETag) + my @if_none_match_lines = grep /If-None-Match/, @FW_httpheader; + my $if_none_match = undef; + if(@if_none_match_lines) { + $if_none_match = $if_none_match_lines[0]; + $if_none_match =~ s/If-None-Match: \"(.*)\"/$1/; + } + + $etag = (stat($path))[9]; #mtime + + if(defined($etag) && defined($if_none_match) && $etag eq $if_none_match) { + print $c "HTTP/1.1 304 Not Modified\r\n", + $FW_headercors, "\r\n"; + return -1; + } } if(!open(FH, $path)) {