Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffering: let #write accept multiple arguments #162

Merged
merged 1 commit into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/openssl/buffering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,11 @@ def do_write(s)
# Writes _s_ to the stream. If the argument is not a String it will be
# converted using +.to_s+ method. Returns the number of bytes written.

def write(s)
do_write(s)
s.bytesize
def write(*s)
s.inject(0) do |written, str|
do_write(str)
written + str.bytesize
end
end

##
Expand Down
9 changes: 9 additions & 0 deletions test/test_pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ def test_write_zero
}
end

def test_write_multiple_arguments
ssl_pair {|s1, s2|
str1 = "foo"; str2 = "bar"
assert_equal 6, s1.write(str1, str2)
s1.close
assert_equal "foobar", s2.read
}
end

def test_partial_tls_record_read_nonblock
ssl_pair { |s1, s2|
# the beginning of a TLS record
Expand Down