lib/httpx/connection/http2.rb in httpx-0.14.5 vs lib/httpx/connection/http2.rb in httpx-0.15.0

- old
+ new

@@ -32,10 +32,16 @@ @max_concurrent_requests = @options.max_concurrent_requests || MAX_CONCURRENT_REQUESTS @max_requests = @options.max_requests || 0 init_connection end + def timeout + return @options.timeout[:operation_timeout] if @handshake_completed + + @options.timeout[:settings_timeout] + end + def interests # waiting for WINDOW_UPDATE frames return :r if @buffer.full? if @connection.state == :closed @@ -115,10 +121,17 @@ handle(request, stream) end end def handle_error(ex) + if ex.instance_of?(TimeoutError) && !@handshake_completed && @connection.state != :closed + @connection.goaway(:settings_timeout, "closing due to settings timeout") + emit(:close_handshake) + settings_ex = SettingsTimeoutError.new(ex.timeout, ex.message) + settings_ex.set_backtrace(ex.backtrace) + ex = settings_ex + end @streams.each_key do |request| emit(:error, request, ex) end @pending.each do |request| emit(:error, request, ex) @@ -310,9 +323,10 @@ @buffer << bytes 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?