On Tue, May 22, 2007 at 06:30:03AM +0900, Chris McMahon wrote: > > Sorry if this gets double-posted: > > Is there any way to get net/http to follow a 302 redirect? Lots of examples in the source; look for it in /usr/lib/ruby/1.8/net/http.rb or somewhere similar on your system. # === Following Redirection # # require 'net/http' # require 'uri' # # def fetch(uri_str, limit = 10) # # You should choose better exception. # raise ArgumentError, 'HTTP redirect too deep' if limit == 0 # # response = Net::HTTP.get_response(URI.parse(uri_str)) # case response # when Net::HTTPSuccess then response # when Net::HTTPRedirection then fetch(response['location'], limit - 1) # else # response.error! # end # end # # print fetch('http://www.ruby-lang.org')