1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/openssl/lib/openssl/buffering.rb (Buffering#gets): added second

optional argument to specify maximum length limit.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2007-12-17 07:06:16 +00:00
parent 1e8c6e2ba4
commit d4f5b77d3a
3 changed files with 14 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Mon Dec 17 16:04:16 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/lib/openssl/buffering.rb (Buffering#gets): added second
optional argument to specify maximum length limit.
Mon Dec 17 16:02:30 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httprequest.rb, lib/webrick/cgi.rb: Request-Line or

View file

@ -99,7 +99,7 @@ module Buffering
ret
end
def gets(eol=$/)
def gets(eol=$/, limit=nil)
idx = @rbuffer.index(eol)
until @eof
break if idx
@ -111,6 +111,9 @@ module Buffering
else
size = idx ? idx+eol.size : nil
end
if limit and limit >= 0
size = [size, limit].min
end
consume_rbuff(size)
end

View file

@ -136,6 +136,11 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
str = "x" * 100 + "\n"
ssl.puts(str)
assert_equal(str, ssl.gets)
str = "x" * 100
ssl.puts(str)
assert_equal(str, ssl.gets("\n", 100))
assert_equal("\n", ssl.gets)
}
# read and write