mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
implemented Connection#exhausted?
an exhausted connection can't service more requests, therefore is unmatchable and can't enqueue more requests to the parser.
This commit is contained in:
parent
ad49df8b34
commit
1ad91d898e
@ -80,6 +80,7 @@ module HTTPX
|
||||
def match?(uri, options)
|
||||
return false if @state == :closing || @state == :closed
|
||||
|
||||
return false if exhausted?
|
||||
(
|
||||
(
|
||||
@origins.include?(uri.origin) &&
|
||||
@ -95,6 +96,8 @@ module HTTPX
|
||||
def mergeable?(connection)
|
||||
return false if @state == :closing || @state == :closed || !@io
|
||||
|
||||
return false if exhausted?
|
||||
|
||||
!(@io.addresses & connection.addresses).empty? && @options == connection.options
|
||||
end
|
||||
|
||||
@ -213,6 +216,10 @@ module HTTPX
|
||||
|
||||
private
|
||||
|
||||
def exhausted?
|
||||
@parser && parser.exhausted?
|
||||
end
|
||||
|
||||
def consume
|
||||
catch(:called) do
|
||||
dread
|
||||
|
@ -31,6 +31,10 @@ module HTTPX
|
||||
emit(:close)
|
||||
end
|
||||
|
||||
def exhausted?
|
||||
!@max_requests.positive?
|
||||
end
|
||||
|
||||
def empty?
|
||||
# this means that for every request there's an available
|
||||
# partial response, so there are no in-flight requests waiting.
|
||||
|
@ -35,11 +35,15 @@ module HTTPX
|
||||
@connection.state == :closed || @streams.empty?
|
||||
end
|
||||
|
||||
def exhausted?
|
||||
@connection.active_stream_count >= @max_concurrent_requests
|
||||
end
|
||||
|
||||
def <<(data)
|
||||
@connection << data
|
||||
end
|
||||
|
||||
def send(request, **)
|
||||
def send(request)
|
||||
if !@handshake_completed ||
|
||||
@streams.size >= @max_concurrent_requests
|
||||
@pending << request
|
||||
|
Loading…
x
Reference in New Issue
Block a user