From 0c3d51318538006d2c4393fb96ead184914e5d08 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 5 May 2014 16:38:53 +0000 Subject: * lib/open-uri.rb (OpenURI.open_uri): Call StringIO#close only if the StringIO object is not closed yet. Reported by Jordi Massaguer Pla. [ruby-core:42538] [Bug #6010] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/open-uri/test_open-uri.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/open-uri/test_open-uri.rb') diff --git a/test/open-uri/test_open-uri.rb b/test/open-uri/test_open-uri.rb index 21dd96960a..c6ba652a6b 100644 --- a/test/open-uri/test_open-uri.rb +++ b/test/open-uri/test_open-uri.rb @@ -163,6 +163,29 @@ class TestOpenURI < Test::Unit::TestCase } end + def test_close_in_block_small + with_http {|srv, dr, url| + srv.mount_proc("/close200", lambda { |req, res| res.body = "close200" } ) + assert_nothing_raised { + open("#{url}/close200") {|f| + f.close + } + } + } + end + + def test_close_in_block_big + with_http {|srv, dr, url| + content = "close200big"*10240 + srv.mount_proc("/close200big", lambda { |req, res| res.body = content } ) + assert_nothing_raised { + open("#{url}/close200big") {|f| + f.close + } + } + } + end + def test_header myheader1 = 'barrrr' myheader2 = nil -- cgit v1.2.3