Sha256: 812db29c588861348d46563a35c5dc4b45207da1708fb417e6c91d74863a696c

Contents?: true

Size: 1.17 KB

Versions: 39

Compression:

Stored size: 1.17 KB

Contents

require 'dav4rack/file_resource'

module DAV4Rack
  
  class BuildResource < FileResource

    # TODO: This is a workaround of Rack bug
    # Fix is in master which is incompatible with current Rails (facepalm)
    # https://github.com/rack/rack/commit/7c36a88f73339bebe8b91b27e47ac958a7965f4f
    #
    # The whole method should be removed as soon as new Rack is released
    def get(request, response)
      return super unless stat.directory?

      response.body = ""

      rack_directory = Rack::Directory.new(root).call(request.env)[2]

      rack_directory.files.map do |x|
        x[0].gsub! /^#{Regexp.escape('%2Fbuilds')}/, '/builds'
        x
      end

      rack_directory.each do |line|
        response.body << line
      end
      response['Content-Length'] = response.body.bytesize.to_s
      OK
    end

    def put(*args)
      raise HTTPStatus::Forbidden
    end

    def delete(*args)
      raise HTTPStatus::Forbidden
    end

    def copy(*args)
      raise HTTPStatus::Forbidden
    end

    def move(*args)
      raise HTTPStatus::Forbidden
    end

    def make_collection
      raise HTTPStatus::Forbidden
    end

  protected

    def prop_hash
      {}
    end

  end

end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
smartkiosk-server-0.13.1 lib/dav4rack/build_resource.rb
smartkiosk-server-0.13 lib/dav4rack/build_resource.rb
smartkiosk-server-0.12.1 lib/dav4rack/build_resource.rb
smartkiosk-server-0.12 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.11 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.10 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.9 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.8 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.7 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.6 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.5 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.4 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.3 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.2 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11.1 lib/dav4rack/build_resource.rb
smartkiosk-server-0.11 lib/dav4rack/build_resource.rb
smartkiosk-server-0.10.19 lib/dav4rack/build_resource.rb
smartkiosk-server-0.10.18 lib/dav4rack/build_resource.rb
smartkiosk-server-0.10.17 lib/dav4rack/build_resource.rb
smartkiosk-server-0.10.16 lib/dav4rack/build_resource.rb