lib/httpx/io.rb in httpx-0.0.1 vs lib/httpx/io.rb in httpx-0.0.2

- old
+ new

@@ -1,7 +1,8 @@ # frozen_string_literal: true +require "resolv" require "socket" require "openssl" require "ipaddr" module HTTPX @@ -10,27 +11,28 @@ attr_reader :ip, :port def initialize(hostname, port, options) @state = :idle + @hostname = hostname @options = Options.new(options) @fallback_protocol = @options.fallback_protocol @port = port if @options.io @io = case @options.io when Hash - @ip = TCPSocket.getaddress(hostname) + @ip = Resolv.getaddress(@hostname) @options.io[@ip] || @options.io["#{@ip}:#{@port}"] else @ip = hostname @options.io end unless @io.nil? @keep_open = true @state = :connected end else - @ip = TCPSocket.getaddress(hostname) + @ip = Resolv.getaddress(@hostname) end @io ||= build_socket end def scheme