Skip to content

Instantly share code, notes, and snippets.

@tpitale
Created August 12, 2009 15:48
Show Gist options
  • Select an option

  • Save tpitale/166581 to your computer and use it in GitHub Desktop.

Select an option

Save tpitale/166581 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'curb'
c = Curl::Easy.new("http://bit.ly/g5Fml")
c.follow_location = true
c.max_redirects = 5
location = nil
c.on_header do |d|
matched = d.match(/Location\:(.*)\n/)
location = matched[1] if matched
end
c.perform
puts location if location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment