lib/httpx/channel/http2.rb in httpx-0.0.4 vs lib/httpx/channel/http2.rb in httpx-0.0.5

- old
+ new

@@ -11,11 +11,10 @@ def initialize(buffer, options) @options = Options.new(options) @max_concurrent_requests = @options.max_concurrent_requests init_connection - @retries = options.max_retries @pending = [] @streams = {} @drains = {} @buffer = buffer end @@ -58,10 +57,16 @@ @streams.each do |request, stream| handle(request, stream) end end + def handle_error(ex) + @streams.each_key do |request| + emit(:error, request, ex) + end + end + private def headline_uri(request) request.path end @@ -149,11 +154,15 @@ request.response << data end def on_stream_close(stream, request, error) return handle(request, stream) if request.expects? - response = request.response || ErrorResponse.new(Error.new(error), @retries, @options) - emit(:response, request, response) + if error + emit(:error, request, error) + else + response = request.response + emit(:response, request, response) + end log(level: 2, label: "#{stream.id}: ") { "closing stream" } @streams.delete(request) send(@pending.shift) unless @pending.empty? end