Class: Thrift::SSLSocket
- Inherits:
-
Socket
- Object
- BaseTransport
- Socket
- Thrift::SSLSocket
- Defined in:
- lib/thrift/transport/ssl_socket.rb
Instance Attribute Summary collapse
-
#ssl_context ⇒ Object
Returns the value of attribute ssl_context.
Attributes inherited from Socket
Instance Method Summary collapse
-
#initialize(host = 'localhost', port = 9090, timeout = nil, ssl_context = nil) ⇒ SSLSocket
constructor
A new instance of SSLSocket.
- #open ⇒ Object
- #to_s ⇒ Object
Methods inherited from Socket
Methods inherited from BaseTransport
#close, #flush, #open?, #read, #read_all, #read_byte, #read_into_buffer, #write
Constructor Details
#initialize(host = 'localhost', port = 9090, timeout = nil, ssl_context = nil) ⇒ SSLSocket
Returns a new instance of SSLSocket.
22 23 24 25 |
# File 'lib/thrift/transport/ssl_socket.rb', line 22 def initialize(host='localhost', port=9090, timeout=nil, ssl_context=nil) super(host, port, timeout) @ssl_context = ssl_context end |
Instance Attribute Details
#ssl_context ⇒ Object
Returns the value of attribute ssl_context.
27 28 29 |
# File 'lib/thrift/transport/ssl_socket.rb', line 27 def ssl_context @ssl_context end |
Instance Method Details
#open ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/thrift/transport/ssl_socket.rb', line 29 def open socket = super @handle = OpenSSL::SSL::SSLSocket.new(socket, @ssl_context) begin @handle.connect_nonblock @handle.post_connection_check(@host) @handle rescue IO::WaitReadable IO.select([ @handle ], nil, nil, @timeout) retry rescue IO::WaitWritable IO.select(nil, [ @handle ], nil, @timeout) retry rescue StandardError => e raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}") end end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/thrift/transport/ssl_socket.rb', line 47 def to_s "ssl(#{super.to_s})" end |