def initialize(uri)
http = NetHTTPFetcher.new
http.ca_path = @@ca_path if @@ca_path
headers = {'Accept' => 'application/xrds+xml'}
response = http.get(uri, headers)
raise YADISHTTPError, "Could not fetch #{uri}" if response.nil?
uri, resp_payload = response
xrds_uri = uri
header = resp_payload['x-xrds-location']
header = resp_payload['x-yadis-location'] if header.nil?
if header
xrds_uri = header
response = http.get(xrds_uri)
raise YADISHTTPError, "Could not fetch XRDS #{xrds_uri}" if response.nil?
resp_payload = response[1]
end
unless resp_payload['content-type'] == 'application/xrds+xml'
loc = html_yadis_location(resp_payload.body)
unless loc.nil?
xrds_uri, resp_payload = http.get(loc)
end
end
xrds = XRDS.parse(resp_payload.body)
raise YADISParseError, "Bad XRDS" if xrds.nil?
@uri = uri
@xrds_uri = xrds_uri
@xrds = xrds
end