Method: HTTPX::SSL#connect

Defined in:
lib/httpx/io/ssl.rb

#connectObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/httpx/io/ssl.rb', line 49

def connect
  super
  if @keep_open
    @state = :negotiated
    return
  end
  return if @state == :negotiated ||
            @state != :connected
  unless @io.is_a?(OpenSSL::SSL::SSLSocket)
    @io = OpenSSL::SSL::SSLSocket.new(@io, @ctx)
    @io.hostname = @hostname
    @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
end