Public Instance methods
copy(src, dest)
[show source]
# File lib/httpx/plugins/webdav.rb 16 def copy(src, dest) 17 request("COPY", src, headers: { "destination" => @options.origin.merge(dest) }) 18 end
lock(path, timeout: nil, &blk)
[show source]
# File lib/httpx/plugins/webdav.rb 24 def lock(path, timeout: nil, &blk) 25 headers = {} 26 headers["timeout"] = if timeout && timeout.positive? 27 "Second-#{timeout}" 28 else 29 "Infinite, Second-4100000000" 30 end 31 xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" \ 32 "<D:lockinfo xmlns:D=\"DAV:\">" \ 33 "<D:lockscope><D:exclusive/></D:lockscope>" \ 34 "<D:locktype><D:write/></D:locktype>" \ 35 "<D:owner>null</D:owner>" \ 36 "</D:lockinfo>" 37 response = request("LOCK", path, headers: headers, xml: xml) 38 39 return response unless response.is_a?(Response) 40 41 return response unless blk && response.status == 200 42 43 lock_token = response.headers["lock-token"] 44 45 begin 46 blk.call(response) 47 ensure 48 unlock(path, lock_token) 49 end 50 51 response 52 end
mkcol(dir)
[show source]
# File lib/httpx/plugins/webdav.rb 58 def mkcol(dir) 59 request("MKCOL", dir) 60 end
move(src, dest)
[show source]
# File lib/httpx/plugins/webdav.rb 20 def move(src, dest) 21 request("MOVE", src, headers: { "destination" => @options.origin.merge(dest) }) 22 end
propfind(path, xml = nil)
[show source]
# File lib/httpx/plugins/webdav.rb 62 def propfind(path, xml = nil) 63 body = case xml 64 when :acl 65 '<?xml version="1.0" encoding="utf-8" ?><D:propfind xmlns:D="DAV:"><D:prop><D:owner/>' \ 66 "<D:supported-privilege-set/><D:current-user-privilege-set/><D:acl/></D:prop></D:propfind>" 67 when nil 68 '<?xml version="1.0" encoding="utf-8"?><DAV:propfind xmlns:DAV="DAV:"><DAV:allprop/></DAV:propfind>' 69 else 70 xml 71 end 72 73 request("PROPFIND", path, headers: { "depth" => "1" }, xml: body) 74 end
proppatch(path, xml)
[show source]
# File lib/httpx/plugins/webdav.rb 76 def proppatch(path, xml) 77 body = "<?xml version=\"1.0\"?>" \ 78 "<D:propertyupdate xmlns:D=\"DAV:\" xmlns:Z=\"http://ns.example.com/standards/z39.50/\">#{xml}</D:propertyupdate>" 79 request("PROPPATCH", path, xml: body) 80 end
unlock(path, lock_token)
[show source]
# File lib/httpx/plugins/webdav.rb 54 def unlock(path, lock_token) 55 request("UNLOCK", path, headers: { "lock-token" => lock_token }) 56 end