title: Detect redirect with ruby mechanize
body: <p>I am using the mechanize/nokogiri gems to parse some random pages. I am having problems with 301/302 redirects. Here is a snippet of the code:</p>
  
  <pre><code>agent = Mechanize.new
  page = agent.get('http://example.com/page1')
  </code></pre>
  
  <p>The test server on mydomain.com will redirect the page1 to page2 with 301/302 status code, therefore I was expecting to have</p>
  
  <pre><code>page.code == "301"
  </code></pre>
  
  <p>Instead I always get <code>page.code == "200"</code>.</p>
  
  <p>My requirements are:</p>
  
  <ul>
  <li>I want redirects to be followed (default mechanize behavior, which is good)</li>
  <li>I want to be able to detect that page was actually redirected</li>
  </ul>
  
  <p>I know that I can see the page1 in <code>agent.history</code>, but that's not reliable. I want the redirect status code also.</p>
  
  <p>How can I achieve this behavior with mechanize?</p>