I'm new to ruby, and I've run into a problem while reading 'Programming
Ruby'. The 'Basic Input and Output' chapter has this example (I've added the
'puts' statements):
require 'net/http'
h = Net::HTTP.new('www.pragmaticprogrammer.com', 80)
puts 'before get'
resp, data = h.get('/index.html', nil)
puts 'after get'
if resp.message == "OK"
data.scan(/<img src="(.*?)"/) { |x| puts x }
end
The above code hangs (but terminates ok with ctl-break) after 'before get',
and never reaches 'after get'. There is something up with my machine,
because a coworker can run this fine on his.
Things I've tried :
1. 'ping www.pragmaticprogrammer.com
<http://www.pragmaticprogrammer.com/> ' from the same command prompt. This
works fine.
2. try with other web sites. No difference
3. uninstalled, registry cleanup (CCleaner), reboot and
reinstalled ruby versions 182-14 and 182-15. No difference.
4. 'gem list ---remote' output gets to 'Updating Gem source
index for::/gems.rubyforge.org' and then hangs just like the above code.
5. Turned off firewall (ZoneAlarm) and anti-spyware (Microsoft).
No difference.
6. Added exception handling. No difference.
Any suggestions?
Ken
ruby --version
ruby 1.8.2 (2004-12-25) [i386-mswin32]