Class: Net::DAV

Inherits:
Object
  • Object
show all
Defined in:
lib/adobe_crx/client.rb

Defined Under Namespace

Classes: NetHttpHandler

Instance Method Summary collapse

Instance Method Details

#propfind_size(path) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/adobe_crx/client.rb', line 23

def propfind_size(path)
  headers = {'Depth' => 'infinity'}
  body = '<?xml version="1.0" encoding="utf-8"?><DAV:propfind xmlns:DAV="DAV:"><DAV:prop><DAV:getcontentlength/></DAV:prop></DAV:propfind>'
  res = @handler.request(:propfind, path, body, headers)
  total_size = 0
  xml = Nokogiri::XML.parse(res.body)
  namespaces = {'x' => "DAV:"}
  xml./('.//x:response', namespaces).each do |item|
    begin
      total_size = total_size + item.%(".//x:getcontentlength", namespaces).inner_text.to_i
    rescue Exception
      #nothing
    end
  end
  total_size
end