mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[ruby/openssl] Introduce basic support for close_read and close_write.
https://github.com/ruby/openssl/commit/c99d24cee9
This commit is contained in:
parent
8fb430c1da
commit
1699772ac4
@ -459,6 +459,17 @@ ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
|
||||
nil
|
||||
end
|
||||
|
||||
# Close the stream for reading.
|
||||
def close_read
|
||||
# Unsupported and ignored.
|
||||
# Just don't read any more.
|
||||
end
|
||||
|
||||
# Close the stream for writing.
|
||||
def close_write
|
||||
stop
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def using_anon_cipher?
|
||||
|
||||
@ -117,6 +117,30 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
|
||||
}
|
||||
end
|
||||
|
||||
def test_socket_close_write
|
||||
server_proc = proc do |ctx, ssl|
|
||||
message = ssl.read
|
||||
ssl.write(message)
|
||||
ssl.close_write
|
||||
ensure
|
||||
ssl.close
|
||||
end
|
||||
|
||||
start_server(server_proc: server_proc) do |port|
|
||||
ctx = OpenSSL::SSL::SSLContext.new
|
||||
ssl = OpenSSL::SSL::SSLSocket.open("127.0.0.1", port, context: ctx)
|
||||
ssl.sync_close = true
|
||||
ssl.connect
|
||||
|
||||
message = "abc"*1024
|
||||
ssl.write message
|
||||
ssl.close_write
|
||||
assert_equal message, ssl.read
|
||||
ensure
|
||||
ssl&.close
|
||||
end
|
||||
end
|
||||
|
||||
def test_add_certificate
|
||||
ctx_proc = -> ctx {
|
||||
# Unset values set by start_server
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user