use open directly upon URI objects
require 'open-uri' url = URI.parse('http://www.rubyinside.com/test.txt') url.open { |f| puts f.read }