module HTTPX::Plugins::WebDav::InstanceMethods

  1. lib/httpx/plugins/webdav.rb

Methods

Public Instance

  1. copy
  2. lock
  3. mkcol
  4. move
  5. propfind
  6. proppatch
  7. unlock

Public Instance methods

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