When trying to run the following code from “Programming Ruby” I get an
error message stating
Fetching: www.rubycentral.com
Fetching: www.awl.com
Fetching: www.pragmaticprogrammer.com
Got www.rubycentral.com: OK
/usr/lib/ruby/1.6/net/protocol.rb:221:in error!': 302 "Moved Temporarily" (Net::ProtoRetriableError) from /Users/ilanterrell/Documents/ RubyScripts/threads.rb:20:in
join’
from /Users/ilanterrell/Documents/ RubyScripts/threads.rb:20
from /Users/ilanterrell/Documents/ RubyScripts/threads.rb:20:in
`each’
from /Users/ilanterrell/Documents/ RubyScripts/threads.rb:20
I am pretty new to ruby and I don’t have the slightest clue what “Moved
Temporarily” means. I have tried this on multiple platforms and get the
same error. Any ideas?
#!/usr/bin/ruby
require ‘net/http’
pages = %w( www.rubycentral.com
www.awl.com
www.pragmaticprogrammer.com
)
threads = []
for page in pages
threads << Thread.new(page) { |myPage|
h = Net::HTTP.new(myPage, 80)
puts "Fetching: #{myPage}"
resp, data = h.get(’/’, nil )
puts “Got #{myPage}: #{resp.message}”
}
end
threads.each { |aThread| aThread.join }
ーテレル イラン