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