Sha256: 089ccd94595dbe7653154fd97dcde53629bb143c85af71b6c7b1d7503cca320c
Contents?: true
Size: 778 Bytes
Versions: 7
Compression:
Stored size: 778 Bytes
Contents
require 'time' require 'rack/utils' require 'rack/mime' module DAV4Rack # DAV4Rack::File simply allows us to use Rack::File but with the # specific location we deem appropriate class File < Rack::File attr_accessor :path alias :to_path :path def initialize(path) @path = path end def _call(env) begin if F.file?(@path) && F.readable?(@path) serving else raise Errno::EPERM end rescue SystemCallError not_found end end def not_found body = "File not found: #{Rack::Utils.unescape(env["PATH_INFO"])}\n" [404, {"Content-Type" => "text/plain", "Content-Length" => body.size.to_s, "X-Cascade" => "pass"}, [body]] end end end
Version data entries
7 entries across 7 versions & 1 rubygems