title: Ruby Net::HTTP - following 301 redirects
body: <p>My users submit urls (to mixes on mixcloud.com) and my app uses them to perform web requests.</p>
  
  <p>A <strong>good url</strong> returns a 200 status code:</p>
  
  <pre><code>uri = URI.parse("http://www.mixcloud.com/ErolAlkan/hard-summer-mix/")
  request = Net::HTTP.get_response(uri)(
  #&lt;Net::HTTPOK 200 OK readbody=true&gt;
  </code></pre>
  
  <p>But if you forget the trailing slash then our <em>otherwise good</em> url returns a 301:</p>
  
  <pre><code>uri = "http://www.mixcloud.com/ErolAlkan/hard-summer-mix"
  #&lt;Net::HTTPMovedPermanently 301 MOVED PERMANENTLY readbody=true&gt; 
  </code></pre>
  
  <p>The same thing happens with 404's:</p>
  
  <pre><code># bad path returns a 404
  "http://www.mixcloud.com/bad/path/" 
  # bad path minus trailing slash returns a 301
  "http://www.mixcloud.com/bad/path"
  </code></pre>
  
  <ol>
  <li>How can I 'drill down' into the 301 to see if it takes us on to a valid resource or an error page?</li>
  <li>Is there a tool that provides a comprehensive overview of the rules that a particular domain might apply to their urls?</li>
  </ol>