lib/httpx/connection.rb in httpx-1.2.0 vs lib/httpx/connection.rb in httpx-1.2.1

- old
+ new

@@ -226,15 +226,11 @@ def reset return if @state == :closing || @state == :closed transition(:closing) - unless @write_buffer.empty? - # handshakes, try sending - consume - @write_buffer.clear - end + transition(:closed) end def send(request) if @parser && !@write_buffer.full? @@ -564,10 +560,19 @@ when :inactive return unless @state == :open when :closing return unless @state == :idle || @state == :open + unless @write_buffer.empty? + # preset state before handshake, as error callbacks + # may take it back here. + @state = nextstate + # handshakes, try sending + consume + @write_buffer.clear + return + end when :closed return unless @state == :closing return unless @write_buffer.empty? purge_after_closed @@ -698,10 +703,10 @@ def set_request_timeout(request, timeout, start_event, finish_events, &callback) request.once(start_event) do interval = @timers.after(timeout, callback) Array(finish_events).each do |event| - # clean up reques timeouts if the connection errors out + # clean up request timeouts if the connection errors out request.once(event) do if @intervals.include?(interval) interval.delete(callback) @intervals.delete(interval) if interval.no_callbacks? end