title: Retrieving XRDS document in OpenID using Ruby
body: <p>I am just playing around with the OpenID protocol. I am trying to send Discovery request and retrieve the XRDS document from google . When I try to do it from the terminal using the curl, I am getting the following output</p>
  
  <pre><code>curl --url "https://www.google.com/accounts/o8/id"
      &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)"&gt;
        &lt;XRD&gt;
        &lt;Service priority="0"&gt;
        &lt;Type&gt;http://specs.openid.net/auth/2.0/server&lt;/Type&gt;
        &lt;Type&gt;http://openid.net/srv/ax/1.0&lt;/Type&gt;
        &lt;Type&gt;http://specs.openid.net/extensions/ui/1.0/mode/popup&lt;/Type&gt;
        &lt;Type&gt;http://specs.openid.net/extensions/ui/1.0/icon&lt;/Type&gt;
        &lt;Type&gt;http://specs.openid.net/extensions/pape/1.0&lt;/Type&gt;
        &lt;URI&gt;https://www.google.com/accounts/o8/ud&lt;/URI&gt;
        &lt;/Service&gt;
        &lt;/XRD&gt;
      &lt;/xrds:XRDS&gt;
  </code></pre>
  
  <p>When I try to do the same from the ruby code, It gives me a 302 error and the url to which it has moved points to the same request url.</p>
  
  <pre><code>&lt;HTML&gt;
  &lt;HEAD&gt;
  &lt;TITLE&gt;Moved Temporarily&lt;/TITLE&gt;
  &lt;/HEAD&gt;
  &lt;BODY BGCOLOR="#FFFFFF" TEXT="#000000"&gt;
  &lt;H1&gt;Moved Temporarily&lt;/H1&gt;
  The document has moved &lt;A HREF="https://www.google.com/accounts/o8/id"&gt;here&lt;/A&gt;.
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>  require 'net/http'
    require 'net/https'
    require 'uri'
    http = Net::HTTP.new(uri.host, uri.port)
  
    response =  Net::HTTP.get_response(URI.parse("http://www.google.com/accounts/o8/id"))
    puts "#{response.read_body}"
  </code></pre>
  
  <p>How to get the XRDS through the code and why is it showing different outputs. Can someone explain it?Thanks</p>