discover (OpenID::Yadis)

    # File lib/openid/yadis/discovery.rb, line 74
        def self.discover(uri)
          result = DiscoveryResult.new(uri)
          begin
            resp = OpenID.fetch(uri, nil, {'Accept' => YADIS_ACCEPT_HEADER})
          rescue Exception
            raise DiscoveryFailure.new("Failed to fetch identity URL #{uri} : #{$!}", $!)
          end
          if resp.code != "200"
            raise DiscoveryFailure.new(
                    "HTTP Response status from identity URL host is not \"200\"."\
                    "Got status #{resp.code.inspect} for #{resp.final_url}", resp)
          end

          # Note the URL after following redirects
          result.normalized_uri = resp.final_url

          # Attempt to find out where to go to discover the document or if
          # we already have it
          result.content_type = resp['content-type']

          result.xrds_uri = self.where_is_yadis?(resp)

          if result.xrds_uri and result.used_yadis_location?
            begin
              resp = OpenID.fetch(result.xrds_uri)
            rescue
              raise DiscoveryFailure.new("Failed to fetch Yadis URL #{result.xrds_uri} : #{$!}", $!)
            end
            if resp.code != "200"
                exc = DiscoveryFailure.new(
                        "HTTP Response status from Yadis host is not \"200\". " +
                                           "Got status #{resp.code.inspect} for #{resp.final_url}", resp)
                exc.identity_url = result.normalized_uri
                raise exc
            end

            result.content_type = resp['content-type']
          end

          result.response_text = resp.body
          return result
        end