lib/httpx/io/ssl.rb in httpx-0.7.0 vs lib/httpx/io/ssl.rb in httpx-0.8.0
- old
+ new
@@ -18,10 +18,14 @@
@ctx.set_params(ctx_options) unless ctx_options.empty?
super
@state = :negotiated if @keep_open
end
+ def interests
+ @interests || super
+ end
+
def protocol
@io.alpn_protocol || super
rescue StandardError
super
end
@@ -60,19 +64,22 @@
@io.sync_close = true
end
@io.connect_nonblock
@io.post_connection_check(@hostname) if @ctx.verify_mode != OpenSSL::SSL::VERIFY_NONE
transition(:negotiated)
- rescue ::IO::WaitReadable,
- ::IO::WaitWritable
+ rescue ::IO::WaitReadable
+ @interests = :r
+ rescue ::IO::WaitWritable
+ @interests = :w
end
# :nocov:
if RUBY_VERSION < "2.3"
- def read(*)
+ def read(_, buffer)
super
rescue ::IO::WaitWritable
+ buffer.clear
0
end
def write(*)
super
@@ -84,9 +91,10 @@
def read(size, buffer)
@io.read_nonblock(size, buffer)
buffer.bytesize
rescue ::IO::WaitReadable,
::IO::WaitWritable
+ buffer.clear
0
rescue EOFError
nil
end
end