module Roda::RodaPlugins::SinatraHelpers::RequestMethods
def send_file(path, opts = OPTS)
def send_file(path, opts = OPTS) res = response headers = res.headers if opts[:type] || !headers[CONTENT_TYPE] res.content_type(opts[:type] || ::File.extname(path), :default => OCTET_STREAM) end disposition = opts[:disposition] filename = opts[:filename] if disposition || filename disposition ||= ATTACHMENT filename = path if filename.nil? res.attachment(filename, disposition) end if lm = opts[:last_modified] last_modified(lm) end file = ::Rack::File.new nil file.path = path s, h, b = file.serving(@env) res.status = opts[:status] || s headers.delete(CONTENT_LENGTH) headers.replace(h.merge!(headers)) res.body = b halt rescue Errno::ENOENT not_found end