lib/dav4rack/controller.rb
# args:: Only argument used: :copy
# Move Resource to new location. If :copy is provided,
# Resource will be copied (implementation ease)
: Only argument used: :copy
Move Resource to new location. If :copy is provided,
Resource will be copied (implementation ease)
: Only argument used : : copy Move Resource to new location . If : copy is provided Resource will be copied ( implementation ease )
def move(*args)
      unless(resource.exist?)
        NotFound
      else
        resource.lock_check if resource.supports_locking? && !args.include(:copy)
        destination = url_unescape(env['HTTP_DESTINATION'].sub(%r{https?://([^/]+)}, ''))
        dest_host = $1
        if(dest_host && dest_host.gsub(/:\d{2,5}$/, '') != request.host)
          BadGateway
        elsif(destination == resource.public_path)
          Forbidden
        else
          collection = resource.collection?
          dest = resource_class.new(destination, clean_path(destination), @request, @response, @options.merge(:user => resource.user))
          status = nil
          if(args.include?(:copy))
            status = resource.copy(dest, overwrite)
          else
            return Conflict unless depth.is_a?(Symbol) || depth > 1
            status = resource.move(dest, overwrite)
          end
          response['Location'] = "#{scheme}://#{host}:#{port}#{url_format(dest)}" if status == Created
          if collection
            multistatus do |xml|
              xml.response do
                xml.href "#{scheme}://#{host}:#{port}#{url_format(status == Created ? dest : resource)}"
                xml.status "#{http_version} #{status.status_line}"
              end
            end
          else
            status
          end
        end
      end
    end
def move ( * args ) unless ( resource . exist? ) NotFound else resource . lock_check if resource . supports_locking? && ! args . include ( :copy ) destination = url_unescape ( env [ 'HTTP_DESTINATION' ] . sub ( %r{ https?://([^/]+) } , '' ) ) dest_host = $1 if ( dest_host && dest_host . gsub ( / : \d {2,5}$ / , '' ) != request . host ) BadGateway elsif ( destination == resource . public_path ) Forbidden else collection = resource . collection? dest = resource_class . new ( destination , clean_path ( destination ) , @request , @response , @options . merge ( :user => resource . user ) ) status = nil if ( args . include? ( :copy ) ) status = resource . copy ( dest , overwrite ) else return Conflict unless depth . is_a? ( Symbol ) || depth > 1 status = resource . move ( dest , overwrite ) end response [ 'Location' ] = "#{scheme}://#{host}:#{port}#{url_format(dest)}" if status == Created if collection multistatus do | xml | xml . response do xml . href "#{scheme}://#{host}:#{port}#{url_format(status == Created ? dest : resource)}" xml . status "#{http_version} #{status.status_line}" end end else status end end end end
args:: Only argument used: :copy
Move Resource to new location.
args :: Only argument used : : copy Move Resource to new location .
# RFC 2518
args
<not_specific>