* 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:
parent
1e8c6e2ba4
commit
d4f5b77d3a
@ -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>
|
Mon Dec 17 16:02:30 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
* lib/webrick/httprequest.rb, lib/webrick/cgi.rb: Request-Line or
|
* lib/webrick/httprequest.rb, lib/webrick/cgi.rb: Request-Line or
|
||||||
|
@ -99,7 +99,7 @@ module Buffering
|
|||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def gets(eol=$/)
|
def gets(eol=$/, limit=nil)
|
||||||
idx = @rbuffer.index(eol)
|
idx = @rbuffer.index(eol)
|
||||||
until @eof
|
until @eof
|
||||||
break if idx
|
break if idx
|
||||||
@ -111,6 +111,9 @@ module Buffering
|
|||||||
else
|
else
|
||||||
size = idx ? idx+eol.size : nil
|
size = idx ? idx+eol.size : nil
|
||||||
end
|
end
|
||||||
|
if limit and limit >= 0
|
||||||
|
size = [size, limit].min
|
||||||
|
end
|
||||||
consume_rbuff(size)
|
consume_rbuff(size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -136,6 +136,11 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
|
|||||||
str = "x" * 100 + "\n"
|
str = "x" * 100 + "\n"
|
||||||
ssl.puts(str)
|
ssl.puts(str)
|
||||||
assert_equal(str, ssl.gets)
|
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
|
# read and write
|
||||||
|
Loading…
x
Reference in New Issue
Block a user