* 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
This commit is contained in:
parent
5ab5d92191
commit
0c3d513185
@ -1,3 +1,9 @@
|
|||||||
|
Tue May 6 01:28:14 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* 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]
|
||||||
|
|
||||||
Tue May 6 01:08:01 2014 Koichi Sasada <ko1@atdot.net>
|
Tue May 6 01:08:01 2014 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* benchmark/driver.rb: define File::NULL if not defiend and /dev/null
|
* benchmark/driver.rb: define File::NULL if not defiend and /dev/null
|
||||||
|
@ -155,7 +155,7 @@ module OpenURI
|
|||||||
if io.respond_to? :close!
|
if io.respond_to? :close!
|
||||||
io.close! # Tempfile
|
io.close! # Tempfile
|
||||||
else
|
else
|
||||||
io.close
|
io.close if !io.closed?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -163,6 +163,29 @@ class TestOpenURI < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
end
|
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
|
def test_header
|
||||||
myheader1 = 'barrrr'
|
myheader1 = 'barrrr'
|
||||||
myheader2 = nil
|
myheader2 = nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user