diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-03 12:15:02 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-03 12:15:02 +0000 |
| commit | 5facf7e22f0c0397827c8fcb74aad74ff3adbaa2 (patch) | |
| tree | 675678d7639b174bcb5dc397c23e6406e4d5e15e /test | |
| parent | f81cdb36abe93a029c8c1f7d7a96dfa019abfb49 (diff) | |
* lib/net/http.rb (Net::HTTP#request): close @socket only after
started. [ruby-core:28028]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -rw-r--r-- | test/net/http/test_connection.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/net/http/test_connection.rb b/test/net/http/test_connection.rb new file mode 100644 index 0000000000..d5610ce1d8 --- /dev/null +++ b/test/net/http/test_connection.rb @@ -0,0 +1,33 @@ +require 'net/http' +require 'test/unit' + +module TestHTTP + class HTTPConnectionTest < Test::Unit::TestCase + def test_connection_refused_in_request + bug2708 = '[ruby-core:28028]' + port = nil + localhost = "127.0.0.1" + t = Thread.new { + TCPServer.open(localhost, 0) do |serv| + _, port, _, _ = serv.addr + if clt = serv.accept + clt.close + end + end + } + begin + sleep 0.1 until port + assert_raise(Errno::ECONNRESET, bug2708) { + n = Net::HTTP.new(localhost, port) + n.request_get('/') + } + ensure + t.join if t + end + assert_raise(Errno::ECONNREFUSED, bug2708) { + n = Net::HTTP.new(localhost, port) + n.request_get('/') + } + end + end +end |
