<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ruby on The Shadow File</title>
    <link>https://shadowfile.inode.link/tags/ruby/</link>
    <description>Recent content in Ruby on The Shadow File</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sun, 15 Mar 2009 09:18:00 -0700</lastBuildDate>
    <atom:link href="https://shadowfile.inode.link/tags/ruby/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Handling HTTP Redirection in Ruby</title>
      <link>https://shadowfile.inode.link/blog/2009/03/handling-http-redirection-in-ruby/</link>
      <pubDate>Sun, 15 Mar 2009 09:18:00 -0700</pubDate>
      <guid>https://shadowfile.inode.link/blog/2009/03/handling-http-redirection-in-ruby/</guid>
      <description>&lt;p&gt;I have a Ruby project where I&amp;rsquo;m dumping a bunch of bookmarks from&#xA;delicious.com, then fetching each bookmarked page for analysis.&lt;/p&gt;&#xA;&lt;p&gt;One of the problems I encountered early on is that the some of the web&#xA;pages bookmarked would redirect to some other location. Simply checking&#xA;for HTTP response code 200 was insufficient. I needed to check for&#xA;redirection as well.&lt;/p&gt;&#xA;&lt;p&gt;A quick Google search for &amp;ldquo;ruby follow http redirect&amp;rdquo; yields lots of&#xA;&lt;a href=&#34;http://www.google.com/search?q=ruby&amp;#43;follow&amp;#43;http&amp;#43;redirect&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a&#34; target=&#34;_blank&#34;&gt;results&lt;/a&gt;.&#xA;Unfortunately, they&amp;rsquo;re all very similar, and not quite right. In&#xA;general, the examples you come across (even the one in the official Ruby&#xA;documentation) don&amp;rsquo;t handle the case when the redirected location is&#xA;path relative to the original location. So you end up doing a get on a&#xA;URL that looks like &amp;ldquo;../../redirected/location/index.html,&amp;rdquo; which&#xA;clearly won&amp;rsquo;t work.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
