24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/httpx/plugins/webdav.rb', line 24
def lock(path, timeout: nil, &blk)
= {}
["timeout"] = if timeout && timeout.positive?
"Second-#{timeout}"
else
"Infinite, Second-4100000000"
end
xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" \
"<D:lockinfo xmlns:D=\"DAV:\">" \
"<D:lockscope><D:exclusive/></D:lockscope>" \
"<D:locktype><D:write/></D:locktype>" \
"<D:owner>null</D:owner>" \
"</D:lockinfo>"
response = request("LOCK", path, headers: , xml: xml)
return response unless response.is_a?(Response)
return response unless blk && response.status == 200
lock_token = response.["lock-token"]
begin
blk.call(response)
ensure
unlock(path, lock_token)
end
response
end
|