# File rbot/utils.rb, line 146def Utils.http_get(uristr, readtimeout=8, opentimeout=4)
# ruby 1.7 or better needed for this (or 1.6 and debian unstable)
Net::HTTP.version_1_2
# (so we support the 1_1 api anyway, avoids problems)
uri = URI.parse uristr
query = uri.path
if uri.query
query += "?#{uri.query}"
end
proxy_host = nil
proxy_port = nilif(ENV['http_proxy'] && proxy_uri = URI.parse(ENV['http_proxy']))
proxy_host = proxy_uri.host
proxy_port = proxy_uri.port
end
http = Net::HTTP.new(uri.host, uri.port, proxy_host, proxy_port)
http.open_timeout = opentimeout
http.read_timeout = readtimeout
http.start {|http|
begin
resp , = http.get(query)
if resp.code == "200"return resp.body
endrescue => e
# cheesy for now
$stderr.puts "Utils.http_get exception: #{e}, while trying to get #{uristr}"
returnnilend
}
end