class Rack::Files

def get(env)

Experimental RBS support (using type sampling data from the type_fusion project).

def get: (Hash env) -> untyped

This signature was generated using 1 sample from 1 application.

def get(env)
  request = Rack::Request.new env
  unless ALLOWED_VERBS.include? request.request_method
    return fail(405, "Method Not Allowed", { 'Allow' => ALLOW_HEADER })
  end
  path_info = Utils.unescape_path request.path_info
  return fail(400, "Bad Request") unless Utils.valid_path?(path_info)
  clean_path_info = Utils.clean_path_info(path_info)
  path = ::File.join(@root, clean_path_info)
  available = begin
    ::File.file?(path) && ::File.readable?(path)
  rescue SystemCallError
    # Not sure in what conditions this exception can occur, but this
    # is a safe way to handle such an error.
    # :nocov:
    false
    # :nocov:
  end
  if available
    serving(request, path)
  else
    fail(404, "File not found: #{path_info}")
  end
end