Sha256: bf4aeb783cb427eebd75e8ffa01992eb7e6fe213a3bd29644d4e1f43cbef83e2

Contents?: true

Size: 782 Bytes

Versions: 6

Compression:

Stored size: 782 Bytes

Contents

require "socket"

module Bunny
  begin
    require "openssl"

    class SSLSocket < OpenSSL::SSL::SSLSocket
      def read_fully(count, timeout = nil)
        return nil if @eof

        value = ''
        begin
          loop do
            value << read_nonblock(count - value.bytesize)
            break if value.bytesize >= count
          end
        rescue EOFError
          @eof = true
        rescue Errno::EAGAIN, Errno::EWOULDBLOCK, OpenSSL::SSL::SSLError => e
          puts e.inspect
          if IO.select([self], nil, nil, timeout)
            retry
          else
            raise Timeout::Error, "IO timeout when reading #{count} bytes"
          end
        end
        value
      end
    end
  rescue LoadError => le
    puts "Could not load OpenSSL"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bunny-0.9.0.pre13 lib/bunny/ssl_socket.rb
bunny-0.9.0.pre12 lib/bunny/ssl_socket.rb
bunny-0.9.0.pre11 lib/bunny/ssl_socket.rb
bunny-0.9.0.pre10 lib/bunny/ssl_socket.rb
bunny-0.9.0.pre9 lib/bunny/ssl_socket.rb
bunny-0.9.0.pre8 lib/bunny/ssl_socket.rb