lib/httpx/channel.rb in httpx-0.0.3 vs lib/httpx/channel.rb in httpx-0.0.4

- old
+ new

@@ -194,10 +194,18 @@ emit(:promise, *args) end parser.on(:close) do transition(:closing) end + parser.on(:reset) do + transition(:closing) + unless parser.empty? + transition(:closed) + transition(:idle) + transition(:open) + end + end parser end def transition(nextstate) case nextstate @@ -216,18 +224,21 @@ @io.close @read_buffer.clear end @state = nextstate rescue Errno::ECONNREFUSED, - Errno::EADDRNOTAVAIL => e + Errno::ENETUNREACH, + Errno::EADDRNOTAVAIL, + OpenSSL::SSL::SSLError => e + # connect errors, exit gracefully emit_error(e) @state = :closed emit(:close) end def emit_error(e) response = ErrorResponse.new(e, 0, @options) - @pending.each do |request, _| # rubocop:disable Performance/HashEachMethods + @pending.each do |request, _| emit(:response, request, response) end end end end