ETag stuff must respect the cacheable parameter

git-svn-id: https://svn.fhem.de/fhem/trunk@2220 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig
2012-11-29 11:57:55 +00:00
parent 0833accaf8
commit a3f21c53db

View File

@@ -1245,6 +1245,10 @@ FW_returnFileAsStream($$$$$)
{ {
my ($path, $suffix, $type, $doEsc, $cacheable) = @_; my ($path, $suffix, $type, $doEsc, $cacheable) = @_;
my $etag;
my $c = $FW_chash->{CD};
if($cacheable) {
#Check for If-None-Match header (ETag) #Check for If-None-Match header (ETag)
my @if_none_match_lines = grep /If-None-Match/, @FW_httpheader; my @if_none_match_lines = grep /If-None-Match/, @FW_httpheader;
my $if_none_match = undef; my $if_none_match = undef;
@@ -1253,14 +1257,14 @@ FW_returnFileAsStream($$$$$)
$if_none_match =~ s/If-None-Match: \"(.*)\"/$1/; $if_none_match =~ s/If-None-Match: \"(.*)\"/$1/;
} }
my $c = $FW_chash->{CD}; $etag = (stat($path))[9]; #mtime
my $etag = (stat($path))[9]; #mtime
if(defined($etag) and defined($if_none_match) and $etag eq $if_none_match) { if(defined($etag) && defined($if_none_match) && $etag eq $if_none_match) {
print $c "HTTP/1.1 304 Not Modified\r\n", print $c "HTTP/1.1 304 Not Modified\r\n",
$FW_headercors, "\r\n"; $FW_headercors, "\r\n";
return -1; return -1;
} }
}
if(!open(FH, $path)) { if(!open(FH, $path)) {
FW_pO "<div id=\"content\">$path: $!</div>"; FW_pO "<div id=\"content\">$path: $!</div>";