- local etag = luci.http.protocol.conditionals.mk_etag( stat )
-
- -- Send Response
- return Response(
- 200, {
- ["Date"] = self.date.to_http( os.time() );
- ["Last-Modified"] = self.date.to_http( stat.mtime );
- ["Content-Type"] = self.mime.to_mime( file );
- ["Content-Length"] = stat.size;
- ["ETag"] = etag;
- }
- ), ltn12.source.file(io.open(file))
+ local etag = self.cond.mk_etag( stat )
+
+ -- Check conditionals
+ local ok, code, hdrs
+
+ ok, code, hdrs = self.cond.if_modified_since( request, stat )
+ if ok then
+ ok, code, hdrs = self.cond.if_match( request, stat )
+ if ok then
+ ok, code, hdrs = self.cond.if_unmodified_since( request, stat )
+ if ok then
+ ok, code, hdrs = self.cond.if_none_match( request, stat )
+ if ok then
+ -- Send Response
+ return Response(
+ 200, {
+ ["Date"] = self.date.to_http( os.time() );
+ ["Last-Modified"] = self.date.to_http( stat.mtime );
+ ["Content-Type"] = self.mime.to_mime( file );
+ ["Content-Length"] = stat.size;
+ ["ETag"] = etag;
+ }
+ ), ltn12.source.file(io.open(file))
+ else
+ return Response( code, hdrs or { } ),
+ ltn12.source.empty()
+ end
+ else
+ return Response( code, hdrs or { } ),
+ ltn12.source.empty()
+ end
+ else
+ return Response( code, hdrs or { } ),
+ ltn12.source.empty()
+ end
+ else
+ return Response( code, hdrs or { } ),
+ ltn12.source.empty()
+ end