mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
improve interest calculation
do not check buffer before going to the parsers, which also take that account for http2, use the http2 connection send buffer (instead of the connection buffer) to figure out whether it's waiting on a WINDOW_UPDATE, which is more correct and efficient on http1, the logic is the same, but the code is simplified, as the checks become the same regardless of whether request or @requests.first is picked up
This commit is contained in:
parent
34ad2e325a
commit
375cdf33c1
@ -230,9 +230,6 @@ module HTTPX
|
||||
return @io.interests if connecting?
|
||||
end
|
||||
|
||||
# if the write buffer is full, we drain it
|
||||
return :w unless @write_buffer.empty?
|
||||
|
||||
return @parser.interests if @parser
|
||||
|
||||
nil
|
||||
|
@ -31,14 +31,9 @@ module HTTPX
|
||||
end
|
||||
|
||||
def interests
|
||||
# this means we're processing incoming response already
|
||||
return :r if @request
|
||||
request = @request || @requests.first
|
||||
|
||||
return if @requests.empty?
|
||||
|
||||
request = @requests.first
|
||||
|
||||
return unless request
|
||||
return unless request && request.current_context?
|
||||
|
||||
return :w if request.interests == :w || !@buffer.empty?
|
||||
|
||||
|
@ -52,9 +52,6 @@ module HTTPX
|
||||
end
|
||||
|
||||
def interests
|
||||
# waiting for WINDOW_UPDATE frames
|
||||
return :r if @buffer.full?
|
||||
|
||||
if @connection.state == :closed
|
||||
return unless @handshake_completed
|
||||
|
||||
@ -65,6 +62,19 @@ module HTTPX
|
||||
return @buffer.empty? ? :r : :rw
|
||||
end
|
||||
|
||||
unless @contexts.key?(Fiber.current)
|
||||
return :w unless @pings.empty?
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
unless @connection.send_buffer.empty?
|
||||
return :rw unless @buffer.empty?
|
||||
|
||||
# waiting for WINDOW_UPDATE frames
|
||||
return :r
|
||||
end
|
||||
|
||||
return :w if !@pending.empty? && can_buffer_more_requests?
|
||||
|
||||
return :w unless @drains.empty?
|
||||
@ -72,10 +82,10 @@ module HTTPX
|
||||
if @buffer.empty?
|
||||
return if @streams.empty? && @pings.empty?
|
||||
|
||||
return :r
|
||||
:r
|
||||
else
|
||||
:w
|
||||
end
|
||||
|
||||
:rw
|
||||
end
|
||||
|
||||
def close
|
||||
|
Loading…
x
Reference in New Issue
Block a user