diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/openssl/buffering.rb | 4 | ||||
-rw-r--r-- | lib/openssl/ssl.rb | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/openssl/buffering.rb b/lib/openssl/buffering.rb index 31dcdf1..7ad12d7 100644 --- a/lib/openssl/buffering.rb +++ b/lib/openssl/buffering.rb @@ -32,6 +32,8 @@ module Buffering @rbuffer = "" unless defined? @rbuffer begin @rbuffer << self.sysread(BLOCK_SIZE) + rescue Errno::EAGAIN + retry rescue EOFError @eof = true end @@ -84,7 +86,7 @@ module Buffering end def each(eol=$/) - while line = self.gets(eol?) + while line = self.gets(eol) yield line end end diff --git a/lib/openssl/ssl.rb b/lib/openssl/ssl.rb index 9c31fa7..7f61fc2 100644 --- a/lib/openssl/ssl.rb +++ b/lib/openssl/ssl.rb @@ -16,6 +16,7 @@ require "openssl" require "openssl/buffering" +require "fcntl" module OpenSSL module SSL @@ -49,9 +50,18 @@ module OpenSSL end end + module Nonblock + def initialize(*args) + flag = @io.fcntl(Fcntl::F_GETFL) | File::NONBLOCK + @io.fcntl(Fcntl::F_SETFL, flag) + super + end + end + class SSLSocket include Buffering include SocketForwarder + include Nonblock def post_connection_check(hostname) check_common_name = true |