customink/fauxhai — pull request #99 by mthssdrbrg (2014-04-27 11:06:16+00:00)
Title: Follow GitHub redirects for `raw` links

GitHub recently changed domains for user content, such as `raw` links (see https://developer.github.com/changes/2014-04-25-user-content-security/), and as a consequence all "old" links will redirect to the new corresponding link, and `Net::HTTP::Get` doesn't follow redirects at all by default:

```ruby
:001 > url = URI.parse('https://raw.github.com/customink/fauxhai/master/lib/fauxhai/platforms/amazon/2013.09.json')
=> #
:002 > http = Net::HTTP.new(url.host, url.port)
=> #
:003 > http.use_ssl = true
=> true
:004 > request = Net::HTTP::Get.new(url.path)
=> #
:005 > response = http.start { |http| http.request(request) }
=> #
:006 > response['location']
=> "https://raw.githubusercontent.com/customink/fauxhai/master/lib/fauxhai/platforms/amazon/2013.09.json"
```

The effect of this is that platform / data files that aren't already in the gem won't be fetched from GitHub correctly, and Fauxhai will raise an error that it cannot find the requested platform & version combination.

I contemplated solving it using raw `Net::HTTP` but `open-uri` is just so much easier to work with. I suppose `open-uri` will follow redirects forever though, and that _might_ be a Bad Thing™. I wouldn't have any problem with implementing redirects using `Net:HTTP`, if you'd prefer that.

What do you reckon?