Sha256: 69bc83073882c0d3156fa0bb0192a65e6b1130c05d764ed48e1d4880b6f03713

Contents?: true

Size: 623 Bytes

Versions: 2

Compression:

Stored size: 623 Bytes

Contents

module Innate
  class RackFileWrapper
    def initialize(root, cache_control = nil)
      @file = Rack::File.new(root, cache_control)
    end

    def call(env)
      status, header, body = @file.call(env)

      if status == 403
        unless Rack::File::ALLOWED_VERBS.include?(env['REQUEST_METHOD'])
          body = "File not Found: #{Rack::Utils.unescape(env['PATH_INFO'])}\n"
          return 404, {
            'Content-Type' => 'text/plain',
            'Content-Length' => body.size,
            'X-Cascade' => 'pass',
          }, [body]
        end
      end

      return status, header, body
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
innate-2012.03 lib/innate/rack_file_wrapper.rb
innate-2011.12 lib/innate/rack_file_wrapper.rb