Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 012aa34535
Fetching contributors…

Cannot retrieve contributors at this time

22 lines (18 sloc) 0.45 kb
module MyUtil
def numeric?(str)
str.to_i.to_s == str
end
def get_body(url, limit=2)
raise Gist::RedirectError, 'HTTP redirect too deep' if limit.zero?
uri = URI(url)
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true if uri.port == 443
res = https.get(uri.path)
case res
when Net::HTTPSuccess
res.body
when Net::HTTPFound # 302
get_body(res['location'], limit-1)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.