lib/httpx/connection.rb in httpx-0.18.7 vs lib/httpx/connection.rb in httpx-0.19.0

- old
+ new

@@ -42,11 +42,11 @@ def_delegator :@io, :closed? def_delegator :@write_buffer, :empty? - attr_reader :origin, :origins, :state, :pending, :options + attr_reader :io, :origin, :origins, :state, :pending, :options attr_writer :timers def initialize(type, uri, options) @type = type @@ -76,11 +76,15 @@ end # this is a semi-private method, to be used by the resolver # to initiate the io object. def addresses=(addrs) - @io ||= IO.registry(@type).new(@origin, addrs, @options) # rubocop:disable Naming/MemoizedInstanceVariableName + if @io + @io.add_addresses(addrs) + else + @io = IO.registry(@type).new(@origin, addrs, @options) + end end def addresses @io && @io.addresses end @@ -488,17 +492,17 @@ end end def transition(nextstate) handle_transition(nextstate) - rescue Errno::ECONNREFUSED, - Errno::EADDRNOTAVAIL, - Errno::EHOSTUNREACH, - TLSError => e - # connect errors, exit gracefully - handle_error(e) - @state = :closed - emit(:close) + rescue Errno::ECONNREFUSED, + Errno::EADDRNOTAVAIL, + Errno::EHOSTUNREACH, + TLSError => e + # connect errors, exit gracefully + handle_error(e) + @state = :closed + emit(:close) end def handle_transition(nextstate) case nextstate when :idle