lib/roda/plugins/sinatra_helpers.rb
# Use the contents of the file at +path+ as the response body.  See plugin documentation for options.
Use the contents of the file at +path+ as the response body.  See plugin documentation for options.
Use the contents of the file at + path + as the response body . See plugin documentation for options .
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 => 'application/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
          s, h, b = if Rack.release > '2'
            file.serving(self, path)
          else
            file.path = path
            file.serving(@env)
          end
          res.status = opts[:status] || s
          headers.delete("Content-Length")
          headers.replace(h.merge!(headers))
          res.body = b
          halt
        rescue Errno::ENOENT
          not_found
        end
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 => 'application/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 s , h , b = if Rack . release > '2' file . serving ( self , path ) else file . path = path file . serving ( @env ) end res . status = opts [ :status ] || s headers . delete ( "Content-Length" ) headers . replace ( h . merge! ( headers ) ) res . body = b halt rescue Errno :: ENOENT not_found end
Use the contents of the file at +path+ as the response body.
Use the contents of the file at + path + as the response body .
# :nocov: # :nocov:
path
opts