Method: HTTPX::TCP#initialize
- Defined in:
- lib/httpx/io/tcp.rb
#initialize(uri, options) ⇒ TCP
Returns a new instance of TCP.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/httpx/io/tcp.rb', line 14 def initialize(uri, ) @state = :idle @hostname = uri.host = Options.new() @fallback_protocol = .fallback_protocol @port = uri.port if .io @io = case .io when Hash @ip = Resolv.getaddress(@hostname) .io[@ip] || .io["#{@ip}:#{@port}"] else @ip = @hostname .io end unless @io.nil? @keep_open = true @state = :connected end else @ip = Resolv.getaddress(@hostname) end @io ||= build_socket end |