lib/httpx/connection/http2.rb in httpx-0.6.2 vs lib/httpx/connection/http2.rb in httpx-0.6.3

- old
+ new

@@ -39,11 +39,11 @@ @connection << data end def send(request, **) if !@handshake_completed || - @connection.active_stream_count >= @max_concurrent_requests + @streams.size >= @max_concurrent_requests @pending << request return end unless (stream = @streams[request]) stream = @connection.new_stream @@ -105,10 +105,11 @@ def init_connection @connection = HTTP2Next::Client.new(@options.http2_settings) @connection.on(:frame, &method(:on_frame)) @connection.on(:frame_sent, &method(:on_frame_sent)) @connection.on(:frame_received, &method(:on_frame_received)) + @connection.on(:origin, &method(:on_origin)) @connection.on(:promise, &method(:on_promise)) @connection.on(:altsvc) { |frame| on_altsvc(frame[:origin], frame) } @connection.on(:settings_ack, &method(:on_settings)) @connection.on(:goaway, &method(:on_close)) # @@ -222,11 +223,11 @@ ex.set_backtrace(caller) @streams.each_key do |request| emit(:error, request, ex) end end - return unless @connection.state == :closed && @connection.active_stream_count.zero? + return unless @connection.state == :closed && @streams.size.zero? emit(:close) end def on_frame_sent(frame) @@ -261,9 +262,13 @@ emit(:altsvc, origin, alt_origin, origin, params) end def on_promise(stream) emit(:promise, @streams.key(stream.parent), stream) + end + + def on_origin(origin) + emit(:origin, origin) end def respond_to_missing?(meth, *args) @connection.respond_to?(meth, *args) || super end