Bug #2708: NoMethodError exception generated when using net/http http://redmine.ruby-lang.org/issues/show/2708 Author: John Nishinaga Status: Open, Priority: Normal Category: lib ruby -v: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10] I recently stumbled upon what appears to be a bug in lib/net/http.rb. Here is example code that illustrates the problem: require 'net/http' n = Net::HTTP.new('127.0.0.1', 1234) # or any other unused port n.request_head('/') The above code generates a NoMethodError exception, with the message "undefined method `closed?' for nil:NilClass". The expected result, and what was generated in prior versions of Ruby 1.8.7., is a thrown Errno::ECONNREFUSED exception. It appears a recent change (r25851) to lib/net/http.rb changed some exception handling behavior and forgot to check if @socket is set. A proposed patch is attached that adds the additional check. ---------------------------------------- http://redmine.ruby-lang.org