> I try to retrieve some data from an internet site using 
> Net::HTTP.new('host').post('path', 'data') but get the 
> following error.  
> 
> Net::ProtoRetriableError: 302 Found
>   from /usr/local/lib/ruby/1.6/net/protocol.rb:269:in `error!'
>         from /usr/local/lib/ruby/1.6/net/http.rb:1089:in `value'
>         from /usr/local/lib/ruby/1.6/net/http.rb:471:in `post'
>         from (irb):12

I was just playing with this yesterday. The pickaxe book (p. 491) contains
sample code for handling redirects. They recommend using Tomoyuki Kosimizu's
URI package in RAA, but that entry now refers to the URb entry in RAA
(http://www.ruby-lang.org/en/raa-list.rhtml?name=URb) -- which in turn has
internally been renamed to URI :). It was a bit confusing, but I worked it
out. You can download the URb entry above.

The following is updated (and not tested) code from pickaxe for use with
Yamada's URb/URI -- it also attempts to handle pathless redirects. (eg. if
url www.something.com/foo/bar/page.html redirects to simply newpage.html, it
will append /foo/bar/ to the new url so you get /foo/bar/newpage.html)

      host = 'www.something.com'
      port = 80
      h = Net::HTTP.new(host)
      url = URI.parse(url).path
      begin
        resp, data = h.get(url, nil)
      rescue Net::ProtoRetriableError => detail
        head = detail.data
        if head.code == "302"
          uri = URI.parse(head['location'])
          host = uri.host if uri.host != nil
          port = uri.port if uri.port != nil
          if uri.path != nil
            if uri.path[0, 1] != '/'
              url = File.dirname(url) + '/' + uri.path
            else
              url = uri.path
            end
          end
          # h.finish -- this was in pickaxe, but raised an error for me
          # puts '302 redirect'
          # puts('host', host, 'port', port, 'url', url)
          h = Net::HTTP.new(host, port)
          retry
        end  
      end

Chris