Skip to content

Instantly share code, notes, and snippets.

@jheth
Created May 8, 2013 17:15
Show Gist options
  • Select an option

  • Save jheth/5541976 to your computer and use it in GitHub Desktop.

Select an option

Save jheth/5541976 to your computer and use it in GitHub Desktop.
I wanted to capture the redirect location for the visual force salesforce domain. This does just that.
curl = Curl::Easy.http_get('https://tinderbox.na15.visual.force.com')
curl.header_str
http_response, *http_headers = curl.header_str.split(/[\r\n]+/).map(&:strip)
http_headers = Hash[http_headers.flat_map{ |s| s.scan(/^(\S+): (.+)/) }]
http_response # => "HTTP/1.1 200 OK"
http_headers["Location"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment