Sha256: 9e7e24ff20b14792743fd55cb408252347be45059c2c76578ecab4edfdd3fa75

Contents?: true

Size: 1.52 KB

Versions: 74

Compression:

Stored size: 1.52 KB

Contents

module Bunny
  module JRuby
    begin
      require "bunny/cruby/ssl_socket"
      require "openssl"

      # TLS-enabled TCP socket that implements convenience
      # methods found in Bunny::Socket.
      class SSLSocket < Bunny::SSLSocket

        # Reads given number of bytes with an optional timeout
        #
        # @param [Integer] count How many bytes to read
        # @param [Integer] timeout Timeout
        #
        # @return [String] Data read from the socket
        # @api public
        def read_fully(count, timeout = nil)
          return nil if @__bunny_socket_eof_flag__

          value = ''
          begin
            loop do
              value << read_nonblock(count - value.bytesize)
              break if value.bytesize >= count
            end
          rescue EOFError => e
            @__bunny_socket_eof_flag__ = true
          rescue OpenSSL::SSL::SSLError => e
            if e.message == "read would block"
              if IO.select([self], nil, nil, timeout)
                retry
              else
                raise Timeout::Error, "IO timeout when reading #{count} bytes"
              end
            else
              raise e
            end
          rescue *READ_RETRY_EXCEPTION_CLASSES => e
            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
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
bunny-2.11.0 lib/bunny/jruby/ssl_socket.rb
bunny-2.11.0.pre1 lib/bunny/jruby/ssl_socket.rb
bunny-2.10.0 lib/bunny/jruby/ssl_socket.rb
bunny-2.9.2 lib/bunny/jruby/ssl_socket.rb
bunny-2.9.1 lib/bunny/jruby/ssl_socket.rb
bunny-2.6.7 lib/bunny/jruby/ssl_socket.rb
bunny-2.7.4 lib/bunny/jruby/ssl_socket.rb
bunny-2.8.1 lib/bunny/jruby/ssl_socket.rb
bunny-2.9.0 lib/bunny/jruby/ssl_socket.rb
bunny-2.7.3 lib/bunny/jruby/ssl_socket.rb
bunny-2.8.0 lib/bunny/jruby/ssl_socket.rb
bunny-2.7.2 lib/bunny/jruby/ssl_socket.rb
bunny-2.7.1 lib/bunny/jruby/ssl_socket.rb
bunny-2.7.0 lib/bunny/jruby/ssl_socket.rb
bunny-2.6.6 lib/bunny/jruby/ssl_socket.rb
bunny-2.6.5 lib/bunny/jruby/ssl_socket.rb
bunny-2.6.4 lib/bunny/jruby/ssl_socket.rb
bunny-2.6.3 lib/bunny/jruby/ssl_socket.rb
bunny-2.6.2 lib/bunny/jruby/ssl_socket.rb
bunny-2.6.1 lib/bunny/jruby/ssl_socket.rb