Roland Jesse <jesse / cs.uni-magdeburg.de> writes: > Dave Thomas <Dave / Thomases.com> writes: > > > And, just to show how responsive the Ruby developers are, less than 24 > > hours later, Minero Aoki checks in to the CVS tree a new net/http that > > does just that > > Ok, just a quick followup without checking the repository: > > > head = detail.data > > if head.code == "301" > > puts "Need to retry" > > url = head['location'] > > url =~ %r{^http://([^/]+)(.*)} > > host = $1 > > url = $2 > > port = 80 > > Is there support for retrieving the current port number from the http > response? I would much appreciate if there is. The current port number is available in the Net::Http object h = Net::HTTP.new(ARGV[0] || 'www.ruby-lang.org', 80) p h.port #=> 80 Using Tomoyuki Kosimizu's URI package, available in the RAA, you can readily split the information out of the redirect response: if head.code == "301" uri = URI.create(head['location']) host = uri['host'] url = uri['path'] port = uri['port'] h.finish h = Net::HTTP.new(host, port) retry end Between them, do these do what you need? Regards Dave