diff --git a/CHANGED b/CHANGED index 0e343cbdf..e3e5251ec 100644 --- a/CHANGED +++ b/CHANGED @@ -16,7 +16,8 @@ - bugfix: FHEMWEB slider with min > 0 - change: FHEMWEB CORS moved to options - change: FHEMWEB closing old TCP connections - - change: FHEMWEB added "Associated with" to detail-screen + - change: FHEMWEB added "Associated with" to detail-screen (Uli) + - change: FHEMWEB added ETag headers (Matthias) - 2012-10-28 (5.3) - feature: added functions trim, ltrim, rtrim, UntoggleDirect, diff --git a/FHEM/01_FHEMWEB.pm b/FHEM/01_FHEMWEB.pm index 6610af2ba..26f3bfbd0 100755 --- a/FHEM/01_FHEMWEB.pm +++ b/FHEM/01_FHEMWEB.pm @@ -1236,18 +1236,36 @@ sub 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 $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(!open(FH, $path)) { FW_pO "