Project

General

Profile

Actions

Backport #2708

closed

NoMethodError exception generated when using net/http

Added by jingoro (John Nishinaga) over 14 years ago. Updated over 13 years ago.


Description

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


Files

net_http_socket_close.patch (407 Bytes) net_http_socket_close.patch jingoro (John Nishinaga), 02/03/2010 06:26 PM

Related issues 2 (0 open2 closed)

Has duplicate Backport187 - Backport #2758: NoMethodError instead of Errno::ECONNREFUSED when Net::HTTP cannot connectClosed02/19/2010Actions
Has duplicate Backport187 - Backport #2779: Net::HTTP#get raises NoMethodErrorClosed02/22/2010Actions
Actions #1

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r26553.
John, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions #2

Updated by shyouhei (Shyouhei Urabe) over 14 years ago

  • Status changed from Closed to Assigned
  • Assignee set to shyouhei (Shyouhei Urabe)

=begin

=end

Actions #3

Updated by shyouhei (Shyouhei Urabe) over 14 years ago

  • Status changed from Assigned to Closed

=begin
This issue was solved with changeset r27955.
John, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0