Project

General

Profile

This project is closed and read-only.

Actions

Backport #2758

closed

NoMethodError instead of Errno::ECONNREFUSED when Net::HTTP cannot connect

Backport #2758: NoMethodError instead of Errno::ECONNREFUSED when Net::HTTP cannot connect

Added by thatothermitch (Mitch Williams) over 16 years ago. Updated over 15 years ago.

Status:
Closed
Assignee:
-
[ruby-core:28231]

Description

=begin
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.
=end


Related issues 2 (0 open2 closed)

Is duplicate of Backport187 - Backport #2708: NoMethodError exception generated when using net/httpClosedshyouhei (Shyouhei Urabe)Actions
Has duplicate Backport187 - Backport #2779: Net::HTTP#get raises NoMethodErrorClosedActions
Actions

Also available in: PDF Atom