From: Eric Hodel Date: 2006-07-20T07:47:42+09:00 Subject: Re: Net/HTTP is flaky? On Jul 19, 2006, at 2:55 PM, Just Another Victim of the Ambient Morality wrote: > "Eric Hodel" wrote in message > news:087CE005-B271-4B73-9C98-7DF62B1AC652@segment7.net... >> >> $ ruby -rnet/http >> Net::HTTP.start 'en.wikipedia.org' do |http| res = http.get '/'; >> p res; >> end >> # >> >> Matches browser behavior. >> >>> Hell, "/" at "music.com" has _never_ worked and there doesn't >>> appear to >>> be any kind of redirect or anything. >> >> $ ruby -rnet/http >> Net::HTTP.start 'music.com' do |http| res = http.get '/'; p res; end >> # >> >> Redirects to www.music.com in the browser, Net::HTTP matches browser >> behavior. > > Okay, so the site doesn't exist where I think it does and I get > redirected... in my browser. Net::HTTP doesn't get redirected, it > simply > fails. No, it doesn't fail, it gives you a redirect. Follow it. > _This_ behaviour doesn't match my browser. Is there any way I can > get redirected or find out where it wants to redirect me and go there, > myself? Follow the redirect. Look at open-uri for example code. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com