From: Mitch Williams Date: 2010-02-19T02:24:33+09:00 Subject: [ruby-core:28231] [Bug #2758] NoMethodError instead of Errno::ECONNREFUSED when Net::HTTP cannot connect Bug #2758: NoMethodError instead of Errno::ECONNREFUSED when Net::HTTP cannot connect http://redmine.ruby-lang.org/issues/show/2758 Author: Mitch Williams Status: Open, Priority: Normal ruby -v: ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0], MBARI 0x6770, Ruby Enterprise Edition 2010.01 The code: require net/http.rb n = Net::HTTP.new('server-that-is-not-listening-on-port-eighty') n.request_head('/') Used to throw: "Errno::ECONNREFUSED: Connection refused - connect(2)" But after http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25851 the code throws: "NoMethodError: undefined method `closed?' for nil:NilClass" From line 1060 of net/http.rb. It looks like the code was intended to close sockets in the event of an error, but it assumes the socket actually exists. ---------------------------------------- http://redmine.ruby-lang.org