ActionController::RoutingError (No route matches [PROPFIND] '/'): #913

This commit is contained in:
Karel Pičman 2019-11-08 15:27:48 +01:00
parent 09fc80b78b
commit 443f42c5a4

View File

@ -27,7 +27,7 @@ module RedmineDmsf
def initialize(app) def initialize(app)
@rails_app = app @rails_app = app
path = File.join(Redmine::Utils::relative_url_root, 'dmsf','webdav') path = File.join(Redmine::Utils::relative_url_root, %w(dmsf webdav))
@dav_app = Rack::Builder.new{ @dav_app = Rack::Builder.new{
map path do map path do
run DAV4Rack::Handler.new( run DAV4Rack::Handler.new(
@ -57,16 +57,18 @@ module RedmineDmsf
# it will return a 404 along with the X-Cascade header set to 'pass'. # it will return a 404 along with the X-Cascade header set to 'pass'.
if (status == 404) && (headers['X-Cascade'] == 'pass') if (status == 404) && (headers['X-Cascade'] == 'pass')
# The MS web redirector webdav client likes to go up a level and try # The MS web redirector webdav client likes to go up a level and try
# OPTIONS there. We catch that here and respond telling it that just # OPTIONS and PROPFIND there. We catch that here and respond telling it that just
# plain HTTP is going on. # plain HTTP is going on.
if (env['REQUEST_METHOD'].present? && ('OPTIONS'.casecmp(env['REQUEST_METHOD']) == 0)) && if %w(/ /dmsf).include?(env['PATH_INFO'])
(env['PATH_INFO'].present? && env['PATH_INFO'].start_with?('/dmsf')) # * if 'OPTIONS'.casecmp(env['REQUEST_METHOD']) == 0
[ '200', { 'Allow' => 'OPTIONS,HEAD,GET,PUT,POST,DELETE' }, [''] ] [ '200', { 'Allow' => 'OPTIONS,HEAD,GET,PUT,POST,DELETE' }, [''] ]
# * This's a new condition in order to not process WebDAV request which doesn't belong to DMS. But, it might elsif 'PROPFIND'.casecmp(env['REQUEST_METHOD']) == 0
# case problems when acessing /dmsf and consequently / [ '404', {}, [''] ]
else
@rails_app.call env # let Rails handle the request
end
else else
# let Rails handle the request @rails_app.call env # let Rails handle the request
@rails_app.call env
end end
else else
[status, headers, body] [status, headers, body]