Make static_file_handler#etag private

This commit is contained in:
Sdogruyol 2017-02-27 19:21:14 +03:00
parent 2fe27f0890
commit e6af97c256

View file

@ -50,7 +50,7 @@ module Kemal
return call_next(context) return call_next(context)
end end
elsif File.exists?(file_path) elsif File.exists?(file_path)
return if self.etag(context, file_path) return if etag(context, file_path)
minsize = 860 # http://webmasters.stackexchange.com/questions/31750/what-is-recommended-minimum-object-size-for-gzip-performance-benefits ?? minsize = 860 # http://webmasters.stackexchange.com/questions/31750/what-is-recommended-minimum-object-size-for-gzip-performance-benefits ??
context.response.content_type = Utils.mime_type(file_path) context.response.content_type = Utils.mime_type(file_path)
request_headers = context.request.headers request_headers = context.request.headers
@ -79,7 +79,7 @@ module Kemal
end end
end end
def etag(context, file_path) private def etag(context, file_path)
etag = %{W/"#{File.lstat(file_path).mtime.epoch.to_s}"} etag = %{W/"#{File.lstat(file_path).mtime.epoch.to_s}"}
context.response.headers["ETag"] = etag context.response.headers["ETag"] = etag
return false if !context.request.headers["If-None-Match"]? || context.request.headers["If-None-Match"] != etag return false if !context.request.headers["If-None-Match"]? || context.request.headers["If-None-Match"] != etag