class Kiss class StaticFile def initialize(path,mime_type = nil) @path = path @mime_type = mime_type end def finish ext = File.extname(@path)[1..-1] if File.file?(@path) && File.readable?(@path) [200, { "Last-Modified" => File.mtime(@path).rfc822, "Content-Type" => @mime_type || Kiss.mime_type(ext) || "text/plain", "Content-Length" => File.size(@path).to_s }, self] else return [404, {"Content-Type" => "text/plain"}, ["File not found: #{@path}\n"]] end end def each File.open(@path, "rb") { |file| while part = file.read(8192) yield part end } end end end