From: zeeboo Date: 2008-02-16T04:34:57+09:00 Subject: Re: Net::HTTP and handling 302 Redirect On Feb 14, 7:48 pm, Rk Ch wrote: > I meet two kinds of redirect: "Location" response and HTTP-EQUIV="REFRESH"> tag. > > Here's my solution: > ================================================ > require 'net/http' > require 'net/https' > > http = Net::HTTP.new('www.microsoft.com', 80) > resp, data = http.get('/',nil) > > #1."Location" response redirect... > if resp.response['Location']!=nil then > puts 'Direct to: ' + resp.response['Location'] > redirectUrl=resp.response['Location'] > end > > #2. tag redirect... > redirectUrl=data.scan(/ URL=(.*)\">/).to_s > if redirectUrl!=nil then > puts 'Direct to: ' +redirectUrl > end > -- > Posted viahttp://www.ruby-forum.com/. Looks like #1 is all I have to deal with for this particular site. The code definitely got me further, but still in the dark. --- Code response --- postReq object created #posting to new url.. <- "POST /main/authorization/signIn HTTP/1.1\r\nAccept: */*\r\nContent- Type: application/x-www-form-urlencoded\r\nContent-Length: 2\r\nHost: zbcrazy.ning.com\r\n\r\n" <- c:/ruby/lib/ruby/1.8/net/protocol.rb:174:in `write0': undefined method `dump' for # (NoMethodError) from c:/ruby/lib/ruby/1.8/net/protocol.rb:151:in `write' from c:/ruby/lib/ruby/1.8/net/protocol.rb:166:in `writing' from c:/ruby/lib/ruby/1.8/net/protocol.rb:150:in `write' from c:/ruby/lib/ruby/1.8/net/http.rb:1549:in `send_request_with_body' from c:/ruby/lib/ruby/1.8/net/http.rb:1534:in `exec' from c:/ruby/lib/ruby/1.8/net/http.rb:1057:in `request' from c:/ruby/lib/ruby/1.8/net/http.rb:854:in `post' from BACKUPning_send.rb:62 from c:/ruby/lib/ruby/1.8/net/http.rb:547:in `start' from BACKUPning_send.rb:46 --- End Code response ---