From: "Basti S" <basti.steiner / gmx.de>


> Hi,
> i'm usin ver 1.6.7 of ruby . Everytime I try to access a site via Net::HTTP
> and this site has a 302 response code it says
>
> /net/http.rb:1432: in error! : 302 "Found" (Net::ProtoRetriableError)
>
> Ruby terminates the script with this errormessage. But I want to read out
> the new location of the url. Does anybody know how to get this url or if
> there is any possibility to solve this problem?

I don't know about reading the "new" URL, but to prevent the program from
terminating, you should rescue Net::ProtoRetriableError.  There's probably a
superclass you can rescue as well.  Let me see...

irb(main):001:0> require 'net/http'
true
irb(main):003:0> Net::ProtoRetriableError.ancestors
[Net::ProtoRetriableError, Net::ProtocolError, StandardError, Exception,
Object, Kernel]


Yes, I'd rescue Net::ProtocolError, as in

  begin
    header, data = http.get(URL)
  rescue Net::ProtocolError
    STDERR.puts "HTTP retrieval failed"
  end

Gavin