lib/httpx/connection/http2.rb in httpx-1.0.1 vs lib/httpx/connection/http2.rb in httpx-1.0.2

- old
+ new

@@ -33,11 +33,11 @@ @pings = [] @buffer = buffer @handshake_completed = false @wait_for_handshake = @settings.key?(:wait_for_handshake) ? @settings.delete(:wait_for_handshake) : true @max_concurrent_requests = @options.max_concurrent_requests || MAX_CONCURRENT_REQUESTS - @max_requests = @options.max_requests || 0 + @max_requests = @options.max_requests || Float::INFINITY init_connection end def timeout return @options.timeout[:operation_timeout] if @handshake_completed @@ -80,27 +80,21 @@ def empty? @connection.state == :closed || @streams.empty? end def exhausted? - return false if @max_requests.zero? && @connection.active_stream_count.zero? - - @connection.active_stream_count >= @max_requests + !@max_requests.positive? end def <<(data) @connection << data end def can_buffer_more_requests? - if @handshake_completed + (@handshake_completed || !@wait_for_handshake) && @streams.size < @max_concurrent_requests && - @streams.size < @max_requests - else - !@wait_for_handshake && - @streams.size < @max_concurrent_requests - end + @streams.size < @max_requests end def send(request) unless can_buffer_more_requests? @pending << request @@ -114,11 +108,10 @@ end handle(request, stream) true rescue HTTP2Next::Error::StreamLimitExceeded @pending.unshift(request) - emit(:exhausted) end def consume @streams.each do |request, stream| next if request.state == :done @@ -170,11 +163,10 @@ end end def init_connection @connection = HTTP2Next::Client.new(@settings) - @connection.max_streams = @max_requests if @connection.respond_to?(:max_streams=) && @max_requests.positive? @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)) @@ -338,17 +330,10 @@ end def on_settings(*) @handshake_completed = true emit(:current_timeout) - - if @max_requests.zero? - @max_requests = @connection.remote_settings[:settings_max_concurrent_streams] - - @connection.max_streams = @max_requests if @connection.respond_to?(:max_streams=) && @max_requests.positive? - end - - @max_concurrent_requests = [@max_concurrent_requests, @max_requests].min + @max_concurrent_requests = [@max_concurrent_requests, @connection.remote_settings[:settings_max_concurrent_streams]].min send_pending end def on_close(_last_frame, error, _payload) is_connection_closed = @connection.state == :closed