Index: lib/net/http.rb =================================================================== --- lib/net/http.rb (revision 61763) +++ lib/net/http.rb (working copy) @@ -1451,12 +1451,7 @@ # This method never raises Net::* exceptions. # def request(req, body = nil, &block) # :yield: +response+ - unless started? - start { - req['connection'] ||= 'close' - return request(req, body, &block) - } - end + start unless started? if proxy_user() req.proxy_basic_auth proxy_user(), proxy_pass() unless use_ssl? end Index: test/net/http/test_http.rb =================================================================== --- test/net/http/test_http.rb (revision 61763) +++ test/net/http/test_http.rb (working copy) @@ -1037,6 +1037,22 @@ include TestNetHTTPUtils + def test_keep_alive_using_new + http = new + http.keep_alive_timeout = 1 + + res = http.get('/') + assert_kind_of Net::HTTPResponse, res + assert_kind_of String, res.body + + socket = http.instance_variable_get(:@socket) + refute(socket.closed?, 'Expected socket to be kept open') + + res = http.get('/') + assert_kind_of Net::HTTPResponse, res + assert_kind_of String, res.body + end + def test_keep_alive_get_auto_reconnect start {|http| res = http.get('/')