lib/httpx/connection/http1.rb in httpx-1.0.2 vs lib/httpx/connection/http1.rb in httpx-1.1.0

- old
+ new

@@ -13,11 +13,11 @@ attr_reader :pending, :requests def initialize(buffer, options) @options = Options.new(options) @max_concurrent_requests = @options.max_concurrent_requests || MAX_REQUESTS - @max_requests = @options.max_requests || MAX_REQUESTS + @max_requests = @options.max_requests @parser = Parser::HTTP1.new(self) @buffer = buffer @version = [1, 1] @pending = [] @requests = [] @@ -182,11 +182,18 @@ disable else manage_connection(response) end - send(@pending.shift) unless @pending.empty? + if exhausted? + @pending.concat(@requests) + @requests.clear + + emit(:exhausted) + else + send(@pending.shift) unless @pending.empty? + end end def handle_error(ex) if (ex.is_a?(EOFError) || ex.is_a?(TimeoutError)) && @request && @request.response && !@request.response.headers.key?("content-length") && @@ -285,10 +292,10 @@ request.body.chunk! end connection = request.headers["connection"] - connection ||= if request.options.persistent + connection ||= if request.persistent? # when in a persistent connection, the request can't be at # the edge of a renegotiation if @requests.index(request) + 1 < @max_requests "keep-alive" else