Class: HttpVmRepository

Inherits:
VmRepository show all
Defined in:
lib/ovfparse/http_vmrepository.rb

Direct Known Subclasses

HttpsVmRepository

Constant Summary

Constants inherited from VmRepository

VmRepository::ALLOWABLE_PKG_TYPES, VmRepository::ALLOWABLE_PROTOCOLS, VmRepository::STRICT_CHECKING, VmRepository::USE_CACHE

Instance Attribute Summary

Attributes inherited from VmRepository

#protocol, #repo, #url

Instance Method Summary collapse

Methods inherited from VmRepository

ESXParse, FTParse, HTTParse, LSParse, create, #initialize, #simplePackageConstruction, #uri

Constructor Details

This class inherits a constructor from VmRepository

Instance Method Details

#fetchObject



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ovfparse/http_vmrepository.rb', line 46

def fetch
  #retrieve data from http server
  if (raw_html = get)  

    #parse out package list from index html
    package_list = VmRepository::HTTParse(raw_html) 

    #construct package objects based on results
    return simplePackageConstruction(package_list)
  end
end

#getObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ovfparse/http_vmrepository.rb', line 20

def get 
  begin
    url = URI.parse(URI.escape(self.uri))
    req = Net::HTTP::Get.new(url.path)
  rescue
    if(uri.match(/\/$/) == nil)
      begin
        url = URI.parse(URI.escape(self.uri + '/'))
        req = Net::HTTP::Get.new(url.path)
        @url = @url + '/'
      rescue Exception => e
        raise "We tried it with and without a trailing / but it still doesn't work, this thing is broken: " + e.message
        # TODO: log the fact that this repo sucks at life
      end
    else
      raise "This has a trailing slash and it doesn't work so it's a busted URL"
    end
  end

  res = Net::HTTP.start(url.host, url.port) {|http|
    http.request(req)
  }
  res.body
end